Open UKMIITB opened 8 months ago
Getting crash for some devices. Not able to reproduce this but its happening on production. We ship the app using aab bundle
Hi @UKMIITB,
For some devices which present UnsatisfiedLinkError
exceptions, we've received mixed reports that the ReLinker project is helpful. The SQLiteDatabase.loadLibs
method has an overload which accepts a LibraryLoader
interface allowing you to interface with ReLinker. Would you give that a try?
@developernotes Sure will try this. But before that I have one query
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~II4tLM-0_RLY-7OguisUXw==/com.naviapp-gFZaPbri6blefum1gu84QA==/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:1661)
at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:230)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:247)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:226)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:219)
at net.sqlcipher.database.SupportHelper.<init>(SupportHelper.java:31)
at net.sqlcipher.database.SupportFactory.create(SupportFactory.java:43)
At the beginning we faced this error. We upload app as aab bundle on playstore. And for some devices in the split .so
file was not found.
For this in project gradle.properties we added android.disableAutomaticComponentCreation=true
And this seems to have fixed the current issue.
But now we are getting a different issue as mentioned above
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system_ext/lib64/libsqlcipher.so" needed or dlopened by "/apex/com.android.art/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
Does ReLinker project fixes this current issue or will it fix both the issues ? Can you share some more insight on these 2 issues
@developernotes
Is the issue of not accessible for namespace
related to this
https://android-developers.googleblog.com/2016/06/improving-stability-with-private-cc.html
https://developer.android.com/about/versions/nougat/android-7.0-changes#ndk
It seems that libsqlcipher.so is private post Android 7
Hi @UKMIITB,
Are you building a custom Android image? I don't recall seeing an error relating to libnativeloader.so
reporting an issue. Are you building a custom Android image? One thing to note, if your application is being deployed as an AppBundle, you might also consider trying the usage of SplitInstallHelper.loadLibrary(...)
inside your LibraryLoader
implementation provided to SQLiteDatabase.loadLibs
.
@developernotes
No not building any custom android image.
Just added this dependency implementation "net.zetetic:android-database-sqlcipher:4.5.4"
Generating a passphrase And then building
Room.databaseBuilder(
context,
EncryptedDatabase::class.java,
ENCRYPTED_DATABASE_NAME
)
.openHelperFactory(SupportFactory(passphrase))
.build()
Can you elaborate more on how to use SplitInstallHelper.loadLibrary(...)
with SQLCipher
Hi @UKMIITB,
You need to invoke SQLiteDatabase.loadLibs(...)
prior to a database operation as this loads the native library necessary for SQLCipher for Android. The call to loadLibs
accepts a LibraryLoader
implementation, by default it uses something like this:
loadLibs(context, workingDir, new LibraryLoader() {
@Override
public void loadLibraries(String... libNames) {
for (String libName : libNames) {
System.loadLibrary(libName);
}
}
});
In your case, you can provide an alternative LibraryLoader
in your call to loadLibs(...)
in which you would invoke SplitInstallHelper.loadLibrary(...)
instead of using System.loadLibrary(...)
.
@developernotes Sure will try this. But before that I have one query
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/~~II4tLM-0_RLY-7OguisUXw==/com.naviapp-gFZaPbri6blefum1gu84QA==/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:1661) at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:230) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:247) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:226) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:219) at net.sqlcipher.database.SupportHelper.<init>(SupportHelper.java:31) at net.sqlcipher.database.SupportFactory.create(SupportFactory.java:43)
At the beginning we faced this error. We upload app as aab bundle on playstore. And for some devices in the split
.so
file was not found. For this in project gradle.properties we addedandroid.disableAutomaticComponentCreation=true
And this seems to have fixed the current issue.But now we are getting a different issue as mentioned above
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system_ext/lib64/libsqlcipher.so" needed or dlopened by "/apex/com.android.art/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace"
Does ReLinker project fixes this current issue or will it fix both the issues ? Can you share some more insight on these 2 issues
add packagingOptions inside android{} in app-level gradle file
packagingOptions { jniLibs { useLegacyPackaging = true } }
Hi @goldfish07,
Unfortunately, I am unaware if ReLinker resolves this specific issue. We have received sporadic reports of success when using ReLinker.
Another option to investigate within your application is the use of the android:extractNativeLibs
setting within your application manifest, and the related useLegacyPackaging
option in build.gradle. If you adjust your usage of those settings, does the behavior change?
@developernotes
Fatal Exception: java.lang.UnsatisfiedLinkError
may occur when user sideloads app from third-party , useLegacyPackaging
do resolve issue in app bundle. and i never used ReLinker
Hi @goldfish07,
I'm glad to hear that useLegacyPackaging
was helpful for you, thanks for sharing your update!
Expected Behavior
App should not crash
Actual Behavior
App is crashing for some devices as per crashlytics report
Steps to Reproduce
SQLCipher version (can be identified by executing
PRAGMA cipher_version;
):SQLCipher for Android version: implementation "net.zetetic:android-database-sqlcipher:4.5.4"
Are you able to reproduce this issue within the SQLCipher for Android test suite?
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "/system_ext/lib64/libsqlcipher.so" needed or dlopened by "/apex/com.android.art/lib64/libnativeloader.so" is not accessible for the namespace "classloader-namespace" at java.lang.Runtime.loadLibrary0(Runtime.java:1077) at java.lang.Runtime.loadLibrary0(Runtime.java:998) at java.lang.System.loadLibrary(System.java:1661) at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:230) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:247) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:226) at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:219) at net.sqlcipher.database.SupportHelper.(SupportHelper.java:31)
at net.sqlcipher.database.SupportFactory.create(SupportFactory.java:43)
Note: If you are not posting a specific issue for the SQLCipher library, please post your question to the SQLCipher discuss site. Thanks!