2

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.

Salman Younas
  • 340
  • 1
  • 7
  • 20

3 Answers3

5

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'
lessthanoptimal
  • 2,722
  • 2
  • 23
  • 25
  • It worked. Can you help me in that [question](http://stackoverflow.com/questions/37018558/boofcv-android-detect-hand-gestures) related to BoofCV? – Salman Younas May 04 '16 at 04:36
  • using version 0.34, note that you should target api 26 minimum. otherwise, you will get some dex exceptions – Arkady Aug 19 '19 at 08:11
1

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
    }
}
Kumar M
  • 994
  • 6
  • 21
0

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!