I am using SQLCipher with latest dependency by adding compile ‘net.zetetic:android-database-sqlcipher:3.5.1’ in app’s build.gradle file and other attributes of my gradle file are:
Compilation is done successfully but when running on app on device/Emulator with Android version 6.0 app gets crashed.
Following is the log from logcat.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sqlTest.SQLCipherTestApp, PID: 3222
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.sqlTest.SQLCipherTestApp-1/base.apk”],nativeLibraryDirectories=[/data/app/com.sqlTest.SQLCipherTestApp-1/lib/x86, /vendor/lib, /system/lib]]] couldn’t find “libsqlcipher.so”
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:177)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:170)
at com.sqlTest.SQLCipherTestApp.activities.MyApplication.onCreate(MyApplication.java:35)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
To resolve this temporarly I have copied content of jni folder from build/intermediates/exploded-aar/net.zetetic/android-database-sqlcipher/3.5.1/jni and placed into the app/main/jniLibs folder.
Is this the correct way to do this or I am doing something wrong?
I am unable to find the exact tutorial on how to integrate the SQLCipher in Android Studio using dependency for Marshmallow device.
I have changed to compile ‘net.zetetic:android-database-sqlcipher:3.5.1@aar’ and removed the jniLibs folder from app/main. I have cleaned the project and rebuild it. but still I am getting crash
Following is the logcat after change
06-29 20:04:54.007 1544-1544/com.sqlTest.SQLCipherTestApp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sqlTest.SQLCipherTestApp, PID: 1544
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.sqlTest.SQLCipherTestApp-2/base.apk”],nativeLibraryDirectories=[/data/app/com.sqlTest.SQLCipherTestApp-2/lib/arm, /vendor/lib, /system/lib]]] couldn’t find “libsqlcipher.so”
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:177)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:170)
at com.sqlTest.SQLCipherTestApp.activities.MyApplication.onCreate(MyApplication.java:35)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
For anyone using greendao and sqlcipher:
net.sqlcipher.database.SQLiteException: no such collation sequence: LOCALIZED:
Upgrade your greendao change your gradle to:
compile ‘org.greenrobot:greendao-encryption:2.2.2’
compile ‘net.zetetic:android-database-sqlcipher:3.5.1@aar’
Since you have many third-party dependencies, it may be beneficial to create a secondary demo application, add SQLCipher for Android first, then slowly add back all of your additional dependencies to see where the conflict exists.
I found its working perfectly on separate project where less dependencies used.
Thanks for the helping out from this issue and suggesting the different way.
I have changes dependency to {compile ‘net.zetetic:android-database-sqlcipher:3.5.1@aar’}. Not its working fine in marshmallow device (Lava Pixel-v1). But when I run it on Nexus-5X (OS 6.0) and Yu Yureka Plus (OS 5.1.1) its getting crashed. I am attaching the logcat result from Yu Yureka:
--------- beginning of crash
09-05 17:05:31.865 7939-7939/com.nw.support E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nw.support, PID: 7939
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.nw.support-1/base.apk”],nativeLibraryDirectories=[/data/app/com.nw.support-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn’t find “libsqlcipher.so”
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:988)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:177)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:170)
at com.nw.support.activities.MyApplication.onCreate(MyApplication.java:35)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4591)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
@Dinesh the exception shows that your app has arm64 libraries but this is not supported by SQLCipher. You have to be sure you get rid of all 64-bit libraries if you use SQLCipher.
@Dinesh as I said you have to git rid of all 64-bit libraries. Look in the libs subdirectory of your project and look very carefully through all other dependencies. You may want to try the dependencies one at a time until you find out which one or ones have 64-bit libraries.
If this does not make sense please explain exactly which step does not make sense so others can help.
Unfortunately I am not so familiar with Eclipse, Maven, etc. so I don’t think I can help much further than this.
Disclaimer: I am not a part of the SQLCipher organization.
Thanks @Brodybits, to give me at-least one direction to resolve this issue.
Note: I am using android studio (Gradle Build) for my application.
I have sued some gradle dependencies and few jar files. I am listing all of these, if anybody has already worked on it and figured out the libraries using 64-bit binaries can help too.
@Dinesh I suggest you do the hard work yourself. Something like what @developernotes suggested before: create a test app with SQLCipher, make sure the encryption/decryption is working, and then add the other dependencies one at a time until you see which ones trigger the error. There may be more than one.
Some extra tips:
At every point where it does work keep a safe copy somewhere.
You may want to try all the com.android Gradle dependencies together, maybe SQLCipher will work with all of them. Same for the com.google dependencies.
If there are still a lot of dependencies you are not sure about, you may want to try a “divide and conquer” approach. Try half of the outstanding dependencies and if it doesn’t work, cut it in half again.
Good luck and please report if you make any more progress. Maybe this will help someone else someday.