SQLCipher and Google Pixel Android 7.1 (Nougat)



I have android 7.1 nougat phone (Google Pixel). SQLCipher crashes when I call;

protected void onCreate(Bundle savedInstanceState) {
_ SQLiteDatabase.loadLibs(this);_

I configured my gradle app with;

dependencies {
compile fileTree(dir: ‘libs’, include: [’*.jar’])
compile 'net.zetetic:android-database-sqlcipher:3.5.4@aar’
compile group: ‘com.google.code.gson’, name: ‘gson’, version: '2.7’
compile project(path: ‘:nflibrary’)
compile 'com.android.support:appcompat-v7:25.1.0’
compile 'com.android.support:support-v4:25.1.0’
testCompile ‘junit:junit:4.12’

But I still get following in sql crash;

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.zzzzzzzz.xxxxxxxx, PID: 3523
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.zzzzzzzz.xxxxxxxx-2/base.apk”],nativeLibraryDirectories=[/data/app/com.zzzzzzzz.xxxxxxxx-2/lib/x86_64, /data/app/com.zzzzzzzz.xxxxxxxx-2/base.apk!/lib/x86_64, /system/lib64, /vendor/lib64]]] couldn’t find "libsqlcipher.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:984)
at java.lang.System.loadLibrary(System.java:1530)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:196)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:189)
at com.zzzzzzzz.xxxxxxxx.HomeActivity.onCreate(HomeActivity.java:122)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Disconnected from the target VM, address: ‘localhost:8621’, transport: ‘socket’

how do I fix this problem?


Are you sure that you have ARM libraries in your app? Your error message suggests that this APK only has x86 libraries.


hmmm, I assumed I did, do I have to specify somewhere to have arm libraries too?


It should be automatic. However, if you are using APK splits, or product flavors for specific binary targets, you would not be able to use the x86 APK on an ARM device like the Pixel. You might want to examine the APK itself (it’s just a ZIP archive) and see what .so files you have in there.


I have lib/x86;
- libpl_droidsonroids_gif.so
- librsjni.so
- libRSSupport.so
- libsqlcipher.so


You should have lib/x86/, lib/armeabi/, lib/armeabi-v7a/ directories. If you do not, there is an issue in your build process. I just tested one of my sample apps with v3.5.4 of the SQLCipher AAR, and I get all three of those directories in my APK.


any idea how to fix?


Since I have no idea how you are building your app, I cannot really answer that. This sample app is what I tried and works, so you might compare your app/build.gradle file with mine. The GitHub repo uses SQLCipher v3.5.0, but I tried v3.5.4 here and both APKs had the ARM binaries as well as x86.


Those libraries get built when I do a build api, but when I click on debug-run they don’t seem to get made and deployed to device. any ideas ? Do I have to tell it android-studio to deploy those libraries when debugging or something?


No, that should be automatic. With Instant Run turned off, there is no difference between Android Studio telling Gradle to build the app and you telling Gradle to build the app from the command line.

Try a full uninstall and reinstall of the app. If that does not help, disable Instant Run, then do a full uninstall and reinstall of the app.

And if none of that helps, hopefully somebody else has some ideas, as I am about out of them…


so even though I press the “Debug-‘app’” button I should still get everything I need built into apk deployed to phone? hmmmm. This is not happening and I just uninstall app from settings. Disabled instant run “Preferences->Instant Run” -> check mark off. I still get same issue! should I also disable Jit or something?


The paths its searching suggest you have an x64 .so in your libs output and that is being preferred by the device. To the best of my understanding if you run on an x64 Android device and there are x64 libs it will only load libraries of that type. As SQLCipher is not 64bit it won’t find the libsqlcipher.so in the lib/arm64-v8a directory.

I’ve had this before and the best work around was to exclude all the other x64 .so files so it has no option but to load a different variant supported by SQL Cipher.

In the app build.gradle you need something like this:

packagingOptions {
exclude ‘lib/arm64-v8a/libRSSupport.so’ // BAD SQLCIPHER FIX

although it looks like since I have found this fix there might be a better way.

Hope this helps! I only came here to see if there was any developments with 64bit support.