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:
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig{
minSdkVersion 14
targetSdkVersion 23
}
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.