[英]Android Java: BoofCV Integration Problems
我知道这些问题在这里被问了很多次,但提供的解决方案都没有帮助。
我最近尝试使用 Gradle 将 BoofCV 添加到我的 Android Studio 项目中:
apply plugin: 'com.android.application'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.as.recognize2"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.1.1'
compile group: "org.boofcv", name: "all", version: "0.26"
compile group: "org.boofcv", name: "android", version: "0.26"
testCompile 'junit:junit:4.12'
}
这就是我的 build.gradle (app) 的样子。
Gradle Sync 成功,但“运行应用程序” - 构建失败给我这样的错误,我从另一个问题中选择了这样的错误,因为我在我的项目中进行了很多更改,将其改回将非常困难。
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(org.apache.log4j.chainsaw.ControlPanel$1) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
我收到了大量这些错误而且我不会忽略 proguard 配置中的内部类属性。 由于这些错误,构建需要数小时。
然后我从 Boof-CV-Site 下载了所有 Jar - 文件并将它们嵌入到 libs 文件夹中,并注释掉了使用 maven 下载 boofcv 的编译命令。 结果:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
正如您在页面顶部看到的,我已经实现了它。 但是我不能使用 java 插件,因为我已经在使用 Android.Application 插件了。 并且切换回 Java 7 将不起作用,因为新的 Android Studio 2.2.3 不支持它。
现在我下载了源代码并通过使用 File->New->New Module->Import Gradle 并导航到源代码build.gradle
来嵌入它们。 但是它包含很多构建 gradle,它们都不知道idea命令,并且都不包含apply plugin: "java"命令,因此无法使用 compile 函数。 所以我必须手动编辑每个 build.gradle(许多 build.gradle)。
如何在 Android Studio 2.2.3 或更高版本中清楚地安装 Boofcv?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.