在android studip中引入第三方sdk时有时候会报UnsatisfiedLinkError这样的错误:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.eegsmart.enjoysleep-1/base.apk"],nativeLibraryDirectories=[/data/app/com.eegsmart.enjoysleep-1/lib/arm64, /data/app/com.eegsmart.enjoysleep-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libsleepalgo.so"
原因是android studio导入so文件没有编译到apk里面去,所以导致UnsatisfiedLinkError异常,打开app下的build.gradle,在android的defaultConfig标签下加入如下代码:
ndk {
//这里依次添加jnilibs目录下的文件夹名称
abiFilters"armeabi","armeabi-v7a","mips","x86"
}
然后在工程目录下的gradle.properties文件末行添加如下代码:
android.useDeprecatedNdk=true
重新编译,解决问题