简体   繁体   中英

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:

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.

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.

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. 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. 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. And switching back to Java 7 won't work because the new Android Studio 2.2.3 does not support it.

Now I downloaded the source code and embedded them by using File->New->New Module->Import Gradle and navigating to the sources 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. So I would have to edit each build.gradle (many build.gradle's) by hand.

How can I clearly install Boofcv in Android Studio 2.2.3 or above?

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.

EDIT: Check out the first subsection on this wiki page

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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