Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting UnsatisfiedLinkError error #593

Closed
mane91 opened this issue Jun 20, 2022 · 15 comments
Closed

Getting UnsatisfiedLinkError error #593

mane91 opened this issue Jun 20, 2022 · 15 comments
Labels
needs-details Needs additional details to proceed.

Comments

@mane91
Copy link

mane91 commented Jun 20, 2022

Expected Behavior

It should work on all the devices.

Actual Behavior

I am getting the below issue on Samsung Android 8.1.0

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/mnt/asec/<Pacakge_Name>-fUSOv9ma3DwZv4eW/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libsqlcipher.so" segment 1: Permission denied

Steps to Reproduce

SQLCipher version (can be identified by executing PRAGMA cipher_version;):
Version: 4.4.3

SQLCipher for Android version:

Are you able to reproduce this issue within the SQLCipher for Android test suite?

Note: If you are not posting a specific issue for the SQLCipher library, please post your question to the SQLCipher discuss site. Thanks!

@developernotes
Copy link
Member

Hi @mane91

What are the results of running the SQLCipher for Android test suite on this device?

@developernotes developernotes added the needs-details Needs additional details to proceed. label Jun 20, 2022
@mane91
Copy link
Author

mane91 commented Jun 20, 2022

Hi @developernotes,
I don’t have Samsung Android 8.1.0 device but, before posting a question I tried with another device and it is working.
I saw this issue reported in crashlytics on the prod version of my app.

@maxkohne
Copy link

We have also been experiencing these errors / crashes according to Crashlytics.

SqlCipher Version

4.5.1

Android OS Versions

  • 8, 9, and 12

Affected Devices

  • Redmi 6A
  • Galaxy Tab S3
  • Galaxy J7 Prime
  • Galaxy Tab S8
  • Galaxy S22 Ultra
  • Galaxy A53 5G

We do not have any of these devices in-house so we cannot replicate ourselves.

ABI Filters

Here is what we have in build.gradle. These should be supported according to the documentation here.

ndk { abiFilters 'x86_64', 'x86', 'arm64-v8a', 'armeabi-v7a' }

Some Stacktraces

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~6xOJXd8CMivI3P4yKqoyGQ==/<PACKAGE_NAME>-c_RjLwCh_Eh18RFEGVMIPg==/split_config.arm64_v8a.apk!/lib/arm64-v8a/libsqlcipher.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
       at java.lang.Runtime.loadLibrary0(Runtime.java:998)
       at java.lang.System.loadLibrary(System.java:1656)
       at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:227)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:244)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:223)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:216)

or

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/<PACKAGE_NAME>-lJSaVGaeq_Y-qxkCbIFHBQ==/base.apk"],nativeLibraryDirectories=[/data/app/<PACKAGE_NAME>-lJSaVGaeq_Y-qxkCbIFHBQ==/lib/arm, /system/lib]]] couldn't find "libsqlcipher.so"
       at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
       at java.lang.System.loadLibrary(System.java:1669)
       at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:227)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:244)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:223)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:216)

@developernotes
Copy link
Member

Hi @maxkohne

Are you bundling other third-party libraries which contain native libraries supporting architectures beyond your current abiFilters list? If not, could you try removing the abiFilters from your build.gradle to see if that makes a difference?

@maxkohne
Copy link

Yes we currently use other libs with NDK code

@maxkohne
Copy link

maxkohne commented Aug 15, 2022

Hmm actually one coworker has a Galaxy S22 Ultra and it appears to work for him -- not sure why there is a crash report for one of our customers out in the wild... Here is a pic of a crashlytics report for that device from a random user.... Nothing seems off.

Looking at more reports, we just got a new model added to that affected device list. Pixel 6a

Screen Shot 2022-08-15 at 3 48 19 PM

@developernotes
Copy link
Member

developernotes commented Aug 16, 2022

Hi @maxkohne

Thanks for the additional details. We've heard of issues regarding the loading of native libraries on Android. One approach you might consider is utilizing the LibraryLoader interface within SQLCipher for Android in conjunction with the Relinker project. Once you add the relinker dependency, you will just adjust your SQLCipher for Android initialization from this:

SQLiteDatabase.loadLibs(this);

to something like this:

Context context = this;
SQLiteDatabase.loadLibs(context, libraries -> {
    for (String library : libraries) {
      ReLinker.loadLibrary(context, library);
    }
  });

If you give that a try, would you report back your findings?

@maxkohne
Copy link

Yeah. I will try to get this potential solution in this week for our next release. I'll report back my findings in a couple of weeks after we release and give it some time to go out into the wild to our customers.

Thanks for the help!

@maxkohne
Copy link

maxkohne commented Sep 28, 2022

I want to report back on the Relinker fix that was proposed above. It appears to have solved our crashes (mostly)! Our crashes have almost been completely eliminated.

We actually got a couple of new crashes with almost the same error. It's still an UnsatisfiedLinkError with a slight twist.

Here is the new stracktrace:

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/mnt/asec/[app_id]-pcUR68wvsP3sAv1B/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libsqlcipher.so" segment 1: Permission denied
       at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
       at java.lang.System.loadLibrary(System.java:1669)
       at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:227)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:244)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:223)
       at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:216)
       at net.sqlcipher.database.SupportHelper.<init>(SupportHelper.java:31)
       at net.sqlcipher.database.SupportFactory.create(SupportFactory.java:43)

In the previous crash reports (noted above in my previous post), we were getting Fatal Exception: java.lang.UnsatisfiedLinkError.... not found or ....couldn't find but now, after the Relinker code, we are solely getting Fatal Exception: java.lang.UnsatisfiedLinkError... Permission denied. So Relinker fixed the "not found" case.

The "Permission denied" crash is only happening on one device, the Samsung Galaxy J7 V according to our reports. You can see in the stacktrace that the path starts with mnt/asec/.... which seems to indicate a mounted disk of some sort rather than internal storage. It's odd because we only allow our app to be installed on internal storage (from my understanding).

All things being said, I would say that the Relinker solution fixed the crash for us though! Thanks so much. I'll have to figure out the "Permission denied" UnsatisfiedLinkError case now. I highly doubt it's related to Relinker nor SqlCipher.

@developernotes
Copy link
Member

developernotes commented Sep 28, 2022

Hi @maxkohne

That's great news, we are happy to hear ReLinker helped alleviate the issue! Thanks again for sharing your update.

@developernotes
Copy link
Member

Hi @maxkohne,

Quick question: do you deploy your application using App Bundles?

@maxkohne
Copy link

Yes we do. Would that have something to do with this?

@developernotes
Copy link
Member

Hi @maxkohne,

We were looking at another report where a user experienced similar issues, but ReLinker did not address the issue. We thought that in conjunction with ReLinker, and usage of the SplitInstallHelper would address the issue but it did not for @GordonWu. Both applications are being deployed using App Bundles.

@jae-12
Copy link

jae-12 commented Dec 9, 2022

Hey @maxkohne , do you know if your minimum sdk was higher than 23? or lower? I'm having a similar issue and was debating if we should add ReLinker or not but the ReLinker's github README indicates that I won't need it if minsdk is higher than 23.
If you could let me know, it'd be very appreciated.

@maxkohne
Copy link

@jae-12 our minSdk is currently 28. I actually never noticed the minSdk README docs. Interesting...

I looked our crashlytic reports again. They have gone down pretty significantly since we introduced Relinker a while ago. However, we still get a small amount of crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-details Needs additional details to proceed.
Projects
None yet
Development

No branches or pull requests

4 participants