Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Since 2012 we've been bundling the native libs in our apps - it works great, and offers a much better end user experience than the OpenCV Manager (and for that matter a better developer experience).

You can get the native libs from inside the OpenCV4Android download and add them to your own project directly or bundle them in your own .aar. I'm sure you are aware of that Eric (nice book btw)., but others who come across this question may not realise it.

Steps:

  • Download and unpack OpenCV4Android
  • Create a library project in Android Studio
  • Copy the Java src from OpenCV4Android into your libraries /src/main/java directory
  • Copy the native lib directories into /src/main/jniLibs
  • Depend on your new library

If you want to reduce the download size of dependent apps, add a 'splits' directive to the 'android' gradle plugin configuration - something like this:

android {
   // ... 
   splits {
     abi {
       enable true
       reset()
       include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a'
       universalApk false
     }
   }
}

I cannot understand why anyone would think the OpenCV Manager approach is OK, never mind push it to the exclusion of the better alternative.

Producing a .aar is very easy, and having it published to maven central and jcenter also very easy. I suspect having an official .aar available and documented as the straight-forward integration route would do wonders for OpenCV usage on Android!