Crash with SQLCipher at line SQLiteDatabase.loadLibs(context) on android versions >5.0

Hi, I am using SQLCipher 3.5.2 in my Android project. It works perfectly well on devices of version 5.0 and lower. But it throws an exception with devices of version 5.1 onwards. It fails to execute SQLiteDatabase.loadLibs(context) and gives an UnsatisfiedLinkError. I added the library as follows in build.gradle file (using Android Studio):

compile ‘net.zetetic:android-database-sqlcipher:3.5.2@aar’ .

Here is the stack trace:

Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.aclipsa.michelsmix.staging, PID: 22573
java.lang.UnsatisfiedLinkError: com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[dex fi…
D/Error: ERR: exClass=java.lang.UnsatisfiedLinkError
D/Error: ERR: exMsg=com.android.tools.fd.runtime.IncrementalClassLoader$DelegateClassLoader[DexPathList[[d
D/Error: ERR: file=Runtime.java
D/Error: ERR: class=java.lang.Runtime
D/Error: ERR: method=loadLibrary line=367

Is there anything that is missing in the library for it to run on these devices?

Hello @AG16

Are you able to reproduce the error on your devices when you run the SQLCipher for Android test suite? Are you possibly including other 64 bit third-party native libraries within your application? If so, SQLCipher for Android does not support that, here are the details.

It clearly states that it is supported by devices of android version 2.1 to 5.0.1, on the contrary my issue occurs on versions above that.

Importing the test suite in Studio does not recognize the Android SDK path, although I am adding it.

No

The test suite is keep in lock step with the compatibility section of SQLCipher for Android. I will update the README within the test suite to reflect that correctly.

We look forward to hearing your results of the test suite on the device(s) you are experiencing crashing behavior.

Thanks for your reply!

Do you have steps to import the SQLCipher test suite to Android Studio? I am facing multiple issues after importing it. Or if there is any other way I can run these tests on my device without having to build them in Studio?

Hi @AG16

You can open the SQLCipher for Android test suite directly within IntelliJ.

I ran the test suite on the devices on which I am getting crashes in my app. The results were all “OK” (although I could see some exceptions in their logs, not sure if they are irrelevant if all the tests are OK)
What does that suggest?

Also, correct me if I am wrong: On your query above

Shouldn’t the application crash on all the devices(instead of selected ones) if we are using any other 64 bit 3rd party native lib?

I’m glad to hear the issue does not appear to be with SQLCipher for Android itself, however could be related to your third-party libraries being included within the application. The exceptions are possible side effects of various tests. Further analysis of your application dependencies would need to occur.

No, in the event that your run your application on a 32-bit CPU, Android would not attempt to load native libraries from the x86_64, or arm64 folders, however that is not the case in a 64-bit scenario. Are you certain that you are not including any third-party libraries that include 64-bit versions of their native library?

Thanks for your suggestions. I think the problem was that of 64-bit versions that other libraries may be creating. I fixed the issue by following your suggestion in this link SQLCipher for Android - Native Library Support. Added “split” property to my gradle file.

Hi @AG16

I’m glad the issue has been addressed, take care!

Hi developer notes,

I just resolved my issue with “split” in my gradle. But this fix creates multiple APKs. But I need 1 APK which I can use for all the devices and which also resolves the issue. Multiple APKs cannot be released for 1 application. Isn’t there any way that can be done?

Hi @AG16

Deploying multiple APK’s to the app store is supported, you may find this documentation helpful.