Subramanyam G
Subramanyam G

Reputation: 93

Android M crash java.lang.UnsatisfiedLinkError: dlopen failed:

My Android application is crashing and giving me the following error message:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate

Upvotes: 7

Views: 21302

Answers (7)

Murli
Murli

Reputation: 542

Not sure if this will help someone or not but I had similar error and this is how it got fixed for me. My problem was i was having a library module in which I used sqlchiper .so files, these .so files were in my app module, but the dependency to implement this sqlitechiper was in library module build.gradle.

api 'net.xxxx:android-database-sqlcipher:xxx@aar'

But we decided to convert the library module as .aar file and add it to app module as a dependency and this is when i got the crash java.lang.UnsatisfiedLinkError: dlopen failed:. And i was using a sqlitechiper.jar in app layer so i didn't get any compile time errors as well.

Adding the dependency in app layer and removing the sqlitechiper.jar file dependency from app layer has fixed the issue.

After reading several stackoverflow answers I understood that dependencies that are added in .aar files don't include transitively in app layer if u r adding .aar file directly, if u r adding it as a dependency using compile/api/implementation then those will be added transitively.

Upvotes: 1

Carlos Hoyos
Carlos Hoyos

Reputation: 704

I could get it work in more recent SdkVersions by adding the following line to the NDK in the gradle script

android.ndk {
     <...> //rest of lines
     cppFlags.add("-fPIC") //generate position independent code
     <...> 
}

Upvotes: 0

Before anything I must say that I do not understand all the specifics behind that subject, but I'll try to guide you through the path that helped me.

I saw that that problem appeared only when using target version as 23. Reading other posts was easy to identify that that happened with libs compiled with older ndk tools (ndk-build, to be more specific, but I do not know exactly if that tool came later for fulfilling new needs).

It happened with me using libiconv, a dependency from ZBar project. So I thought that recompiling it would help, and helped. I used the ndk-build tool to recompile zbar and iconv libs.

I hope it suffices.

Upvotes: 3

asdf
asdf

Reputation: 107

Try to change targetSdkVersion in build.gradle to 22 and APP_PLATFORM := android-22 in application.mk. That worked in my environment.

Upvotes: 2

dex
dex

Reputation: 5240

Crash is coming because of following fact that has been changed in Android M

"On previous versions of Android, if your app requested the system to load a shared library with text relocations, the system displayed a warning but still allowed the library to be loaded. Beginning in this release, the system rejects this library if your app's target SDK version is 23 or higher. To help you detect if a library failed to load, your app should log the dlopen(3) failure, and include the problem description text that the dlerror(3) call returns. To learn more about handling text relocations, see this guide"

for more details please refer to this link

Upvotes: 14

Sloosh
Sloosh

Reputation: 1691

as a simple answer, you just need to target android 22 sdk instead of android 23 in your build configuration. For example with gradle use:

defaultConfig {
  targetSdkVersion 22
}

Upvotes: 2

user2271109
user2271109

Reputation:

This is related to Android 6.0 (Marshmallow) switching from OpenSSL to BoringSSL.

Your exception is occurring in the referenced library code. Contact the vendor for a fix or manually include the OpenSSL libraries to avoid the issue.

Also see: https://sourcedna.com/blog/20150806/predicting-app-crashes-on-android-m.html

Upvotes: 2

Related Questions