Reputation: 71
I tried to add some new feature to my app, so i imported a aar library which contains a.so file. But after importing, my app crashed everytime because of java.lang.UnsatisfiedLinkError. All the native libs can't be found in my app's lib dir(/data/app/my.package/lib/arm). if i don't import the aar lib, every thing is fine. What should i do to make it right? Thanks.
Upvotes: 3
Views: 1824
Reputation: 71
The reason were still unknown, but I fixed this problem by adding these codes in the build.gradle of the app mudule:
android {
......
packagingOptions {
exclude 'lib/armeabi-v7a/libnative.so'
exclude 'lib/x86/libnative.so'
}
}
Upvotes: 1
Reputation: 11
First, check that you are using the correct architecture for your device.
If you already do it, there must be some incompatibility between architectures. In my case for example I have one library that has only armeabi arch, and another library has armeabi and armeabi-v7. When I delete armeabi-v7 of this last library everything works fine.
Upvotes: 1
Reputation: 344
I have met the same problem! I can tell you how to resolve this in my way. Your aar library must be an AndroidStudio library project. Import it to your app with code. The build.gradle in library project must declare the .so file path.
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
Make sure jniLibs.srcDirs is correct! You can see this in my blog
I hope this will help you!
Upvotes: 0