I am making an app in Android Studio which uses two libraries. A native library with an Android wrapper and a jar-library. For some reason, the native library won't load if the other jar-library is compiled into the project. So if I run the app with only the native library, everything works fine. I add the other jar-library to my gradle-file and boom... an UnsatisfiedLinkError:
java.lang.UnsatisfiedLinkError: Couldn't load MobileOcrEngine from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.app-1, /vendor/lib, /system/lib]]]: findLibrary returned null
My app runs fine when I use this:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
}
The error occurs when I try:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
compile files('libs/realm-0.78.0.jar')
}
or when I try to use the same library but using the Maven repository:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
compile 'io.realm:realm-android:0.78.0'
}
or if I try to place the jar in jniLibs folder:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.android.support:support-v13:21.0.2'
compile project(':wheel')
}
I have no idea where the root of the problem lies. With one of the two libraries, Android Studio or am I doing something wrong?
Note: I know there have been many questions on StackOverflow regarding UnsatisfiedLinkErrors, yet none of these provide solutions for my problem. I have no problem loading the native library if it's the only library I use...