How to use BoofCV in Android Studio?

1.8k Views Asked by At

How can I import BoofCV in my Android Studio project? I have already looked here. I am totally confused. Please provide me a step by step guide. I appreciate your help.

3

There are 3 best solutions below

2
On BEST ANSWER

Adding the line below to app/build.gradle should do the trick

compile group: 'org.boofcv', name: 'android', version: '0.23'

Replace 0.23 with whatever is the current version.

UPDATE In more recent versions you need to do the following instead:

api group: 'org.boofcv', name: 'boofcv-android', version: '0.30'
0
On

When Integrating BoofCV in Android Studio I faced some issues. I am posting those and its solutions here, so that it will be useful for others.

BoofCV Android Support Integration Document Link https://boofcv.org/index.php?title=Android_support

Adding BoofCV in Android Studio

If you are going to use only one module you can add the following code to app/build.gradle

dependencies {
    api group: 'org.boofcv', name: 'boofcv-android', version: '0.34'
}

If you are going to use more than one module you can add the following code to app/build.gradle

dependencies {
    ['boofcv-android', 'boofcv-core'].each { String a -> api group: 'org.boofcv', name: a, version: '0.34' }
}

Conflicts with Android dependencies

If you are getting conflicts error you need to add the following in app/build.gradle

configurations {
    all*.exclude group: "xmlpull", module: "xmlpull"
    all*.exclude group: "org.apache.commons", module: "commons-compress"
    all*.exclude group: "com.thoughtworks.xstream", module: "commons-compress"
}

Failure Verifying Dex Error

If you get failure to verify dex file bad method handle type 7 then you need to add the following in app/build.gradle

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
0
On

For anyone that tried this and still couldn't use Boofcv.

It is important to also add

dependencies {
     api group: 'org.boofcv', name: 'boofcv-core', version: '0.31'
}

I know it sounds kinda obvious, but I didn't find anything that said I explicitly needed to do that. Good luck!