0

I have an app that needs to use OpenCV and another third-party library. I followed this stackoverflow instruction to import the latest version of OpenCV (v3.4.3) and copy the .so files to /app/src/main/jniLibs. The third-party library is packed as an aar file and put in the /app/libs folder.

My app's build.gradle looks like this:

dependencies {
implementation project(':openCVLibrary343')
implementation(name: 'custom', ext: 'aar')
...

The build.gradle also has this setting that (I think) instructs Android Studio to look for the third-party library in the libs folder:

repositories {
flatDir {
    dirs 'libs'
}

While the code compiles fine, I encountered an error when I tried to run the app. Basically, Android Studio complained that the third-party library is no longer found. But when I used "Build > Analyze APK" to look at what is inside the lib folder of the APK file, I found the so files from the third-party library were actually there.

Does anyone has similar problem? I have been searching for an answer for a while but didn't find anything particularly relevant. I am using Android Studio 3.2 with the latest version of Gradle.

1 Answers1

0

OK, I solved the problem myself. The problem is that my third-party library only provides a .so file for armeabi-v7a, whereas OpenCV has a bunch of other folders for different systems. If one copies all the folders to jniLibs, Android would expect the folders other than armeabi-v7a to have the same .so files. So it complained and stopped the app.

The solution is to remove all the other folders from OpenCV from the jniLibs folder and keep only armeabi-v7a.