【问题标题】:How to configure Build.gradle file to include boofcv library in a project for android studio?如何配置 Build.gradle 文件以在 android studio 的项目中包含 boofcv 库?
【发布时间】:2017-10-10 13:44:23
【问题描述】:

我是 android studio 的新手,想在我的项目中包含 boofcv 库。我正在使用 Android Studio 进行开发。我已经完成了以下步骤以包含该库,并坚持使用 build.gradle 配置。

第 1 步:从http://boofcv.org/index.php?title=Download:BoofCV 下载每个编译后的 jar 文件

第 2 步:将 settings.gradle 更新为

    include ':app'
    include ':libs:boofcv-libs'

第 3 步:我的 build.gradle 看起来像:

    apply plugin: 'com.android.application'
    buildscript {
           repositories {
                       jcenter()
                         }
           dependencies {
                       classpath 'com.android.tools.build:gradle:1.2.3'
                        }
                 }
   allprojects {
          repositories {
                    jcenter()
                       }
               }
   dependencies {
         compile fileTree(dir: 'libs', include: ['*.jar'])
                 }

【问题讨论】:

  • compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:20.+'
  • 在你的依赖中添加上面两行。
  • 我刚刚尝试过。错误是找不到 Gradle DSL 方法;编译()

标签: android android-studio android-gradle-plugin boofcv


【解决方案1】:

正如您的项目 build.gradle 文件的注释所示:

// 注意:不要将您的应用程序依赖项放在这里;他们属于

//在各个模块的build.gradle文件中

删除该 gradle 文件中的编译语句:

 compile project(":libs:boofcv-libs")

并将它们复制到其他(模块) build.gradle 并使依赖项如下所示:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:20.+'
    compile project(":libs:boofcv-libs")


}

【讨论】:

    【解决方案2】:

    BoofCV 位于 maven Central 上,因此您也可以执行以下操作:

    ['calibration','feature','geo','ip','recognition','sfm','android'].each
    { String a -> compile group: 'org.boofcv', name: a, version: '0.18' }
    

    如果你只是想要一切,接下来会更容易:

    compile group: 'org.boofcv', name: "all", version: '0.19-SNAPSHOT'
    

    【讨论】:

      【解决方案3】:
      1. 从此页面获取最新版本 https://boofcv.org/index.php?title=Download
      2. 使用此网站将 maven 转换为 gradle 并确保 将 artifactId 更改为 boofcv-android: http://sagioto.github.io/maven2gradle

      所以它会是这样的:

      compile "org.boofcv:boofcv-android:0.27"
      

      this page 中所述,为避免库冲突,请将其添加到 app.gradle:

      // Remove libraries that conflict with libraries already included with Android
      configurations {
          all*.exclude group: "xmlpull", module: "xmlpull"
          all*.exclude group: "org.apache.commons", module: "commons-compress"
      }
      

      【讨论】:

        猜你喜欢
        • 2015-01-31
        • 1970-01-01
        • 2020-06-05
        • 2015-09-14
        • 1970-01-01
        • 1970-01-01
        • 2018-06-05
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多