How to use Java bindings of OpenCV with Android Studio and Gradle
The source
https://github.com/bytedeco/javacpp-presets
Why I write this
Beacuse they didn’t make it clear about how can I use their libs.
I spent 6 hours to figure out how can I simply import it.
The Code
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.god_loves_you"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true //ADD THIS LINE
}
packagingOptions {
exclude('META-INF/native-image/android-x86_64/jnijavacpp/jni-config.json')
exclude('META-INF/native-image/android-x86_64/jnijavacpp/reflect-config.json')
exclude('META-INF/native-image/android-arm64/jnijavacpp/jni-config.json')
exclude('META-INF/native-image/android-arm64/jnijavacpp/reflect-config.json')
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation group: 'org.bytedeco', name: 'javacpp', version: '1.5.4'
implementation group: 'org.bytedeco', name: 'javacpp', version: '1.5.4', classifier: 'android-arm64'
//implementation group: 'org.bytedeco', name: 'javacpp', version: '1.5.4', classifier: 'android-x86_64'
implementation group: 'org.bytedeco', name: 'opencv', version: '4.4.0-1.5.4'
implementation group: 'org.bytedeco', name: 'opencv', version: '4.4.0-1.5.4', classifier: 'android-arm64'
//implementation group: 'org.bytedeco', name: 'opencv', version: '4.4.0-1.5.4', classifier: 'android-x86_64'
implementation group: 'org.bytedeco', name: 'openblas', version: '0.3.10-1.5.4'
implementation group: 'org.bytedeco', name: 'openblas', version: '0.3.10-1.5.4', classifier: 'android-arm64'
//implementation group: 'org.bytedeco', name: 'openblas', version: '0.3.10-1.5.4', classifier: 'android-x86_64'
}