Is there someone who had experience with this error?
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file \"/data/app/org.swig
This helped me. Sharing it for someone who might come up with same issue.
android {
....
defaultConfig {
....
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
}
-if gradle.properties not available then first add that file and
add
android.useDeprecatedNdk=true
-use this code in build.gradle
defaultConfig {
applicationId 'com.example.application'
minSdkVersion 16
targetSdkVersion 21
versionCode 11
versionName "1.1"
ndk {
abiFilters "armeabi"
}
}
`
Some old gradle tools cannot copy .so files into build folder by somehow, manually copying these files into build folder as below can solve the problem:
build/intermediates/rs/{build config}/{support architecture}/
build config: beta/production/sit/uat
support architecture: armeabi/armeabi-v7a/mips/x86
Yet another crash cause and possible solution is described in this article: https://medium.com/keepsafe-engineering/the-perils-of-loading-native-libraries-on-android-befa49dce2db
Briefly:
in build.gradle
dependencies {
implementation 'com.getkeepsafe.relinker:relinker:1.2.3'
}
in code
static {
try {
System.loadLibrary("<your_libs_name>");
} catch (UnsatisfiedLinkError e) {
ReLinker.loadLibrary(context, "<your_libs_name>");
}
}
In my case After running the ndk-build
in the jni
folder the shared library was created under the libs
folder but the path specified in build.gradle
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/jniLibs'
}
so I need to move the created shared library to jnilibs
folder and it worked!
If you are using Android studio, just edit the gradle.properties in the root folder and add android.useDeprecatedNdk=true. Then edit the build.gradle file in your app's folder, set abiFilters as below:
android {
....
defaultConfig {
....
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
}