简体   繁体   English

Android Java:BoofCV 集成问题

[英]Android Java: BoofCV Integration Problems

I know these kind of questions were asked here tons of times and none of the provided solutions helped.我知道这些问题在这里被问了很多次,但提供的解决方案都没有帮助。

I recently tried to add BoofCV to my Android Studio Project using Gradle:我最近尝试使用 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'
}

This is what my build.gradle (app) looks like.这就是我的 build.gradle (app) 的样子。

The Gradle Sync succeed but the "Run App" - Build failed giving me errors like these I picked from another question because I have changed much in my project and changing it back would be very difficult. 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

I get tons of these Errors And i don't wont to ignore the inner class attributes in proguard configs.我收到了大量这些错误而且我不会忽略 proguard 配置中的内部类属性。 Because of these errors the build takes hours.由于这些错误,构建需要数小时。

Then I downloaded all the Jar - Files from The Boof-CV-Site and embedded them into the libs folder and out-commented the compile commands which use maven to download boofcv.然后我从 Boof-CV-Site 下载了所有 Jar - 文件并将它们嵌入到 libs 文件夹中,并注释掉了使用 maven 下载 boofcv 的编译命令。 Result:结果:

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.

As you can see at the top of the page I already implemented it.正如您在页面顶部看到的,我已经实现了它。 But I can't use the java plugin since I am using the Android.Application Plugin already.但是我不能使用 java 插件,因为我已经在使用 Android.Application 插件了。 And switching back to Java 7 won't work because the new Android Studio 2.2.3 does not support it.并且切换回 Java 7 将不起作用,因为新的 Android Studio 2.2.3 不支持它。

Now I downloaded the source code and embedded them by using File->New->New Module->Import Gradle and navigating to the sources build.gradle .现在我下载了源代码并通过使用 File->New->New Module->Import Gradle 并导航到源代码build.gradle来嵌入它们。 But it contains so many build gradles which all don't know the idea command and which all don't contain the apply plugin: "java" command and therefore are not able to use the compile function.但是它包含很多构建 gradle,它们都不知道idea命令,并且都不包含apply plugin: "java"命令,因此无法使用 compile 函数。 So I would have to edit each build.gradle (many build.gradle's) by hand.所以我必须手动编辑每个 build.gradle(许多 build.gradle)。

How can I clearly install Boofcv in Android Studio 2.2.3 or above?如何在 Android Studio 2.2.3 或更高版本中清楚地安装 Boofcv?

I'm not sure what's wrong but here's a working example that I verified last week: source code This is from the latest SNAPSHOT code, but it's configured to use the previous stable release.我不确定出了什么问题,但这是我上周验证的一个工作示例: 源代码这是来自最新的 SNAPSHOT 代码,但它被配置为使用以前的稳定版本。

EDIT: Check out the first subsection on this wiki page编辑:查看此wiki 页面上的第一小节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM