我知道这些问题在这里被问到了很多次,没有提供的解决方案。Android Java:BoofCV集成问题
我最近尝试使用摇篮到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 CONFIGS属性。 由于这些错误,构建需要数小时。
然后我从The 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
来嵌入它们。但它包含如此多的构建等级,它们都不知道的想法命令 和哪些都不包含应用插件:“java”命令因此无法使用编译功能。所以我将不得不手动编辑每个build.gradle(许多build.gradle的)。
如何在Android Studio 2.2.3或更高版本中明确安装Boofcv?
太谢谢你了!你节省了我数天的时间来实现它。我不知道错误发生在哪里,但是排除了wiki页面上指定的库并只导入了必要的库后,我再也没有错误了。谢谢! – fameman
Android Studio/Gradle生成的错误信息很糟糕,并且有点遗漏。很高兴现在正在工作! –