安卓java:BoofCV集成问题
我知道这类问题在这里被问了很多次,但所提供的解决方案都没有帮助
我最近尝试使用Gradle将BoofCV添加到我的Android Studio项目中:
apply plugin: 'com.安卓.application'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
安卓 {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.as.recognize2"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "安卓.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
安卓TestCompile('com.安卓.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.安卓.support', module: 'support-annotations'
})
compile 'com.安卓.support:appcompat-v7:24.1.1'
compile group: "org.boofcv", name: "all", version: "0.26"
compile group: "org.boofcv", name: "安卓", version: "0.26"
testCompile 'junit:junit:4.12'
}
这就是我的身材。gradle(应用程序)看起来像
Gradle同步成功,但“Run App”-Build失败,我从另一个问题中选择了这些错误,因为我在项目中做了很多更改,将其更改回来将非常困难
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站点下载了所有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。应用程序插件已经存在。而切换回Java7将不起作用,因为新的AndroidStudio 2.2.3不支持它
现在我下载了源代码,并使用File->;新->;新模块->;导入Gradle并导航到源build.gradle
。但是它包含了太多的buildgradle,它们都不知道idea命令
所有这些都不包含应用插件:“java”命令,因此无法使用编译函数。所以我必须编辑每个构建。gradle(许多是手工建造的,gradle's)
如何在Android Studio 2.2.3或更高版本中清晰地安装Boofcv
# 1 楼答案
我不确定出了什么问题,但这里有一个我上周验证过的工作示例:source code这是来自最新的快照代码,但它被配置为使用以前的稳定版本
编辑:查看此wiki page上的第一小节