# SQLCipher integration problem

**URL:** <https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487>\
**Category:** Issues\
**Created:** [June 29, 2016, 7:47am UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487 "2016-06-29T07:47:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [June 29, 2016, 7:47am UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/1 "2016-06-29T07:47:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [June 29, 2016, 2:06pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/2 "2016-06-29T14:06:42Z")

</div>

> [@Dinesh](#):
>
> by adding compile ‘net.zetetic:android-database-sqlcipher:3.5.1’ in app’s build.gradle

You are missing the `@aar` portion of the compile statement. Within the dependencies section of your application module, add the following:

```auto
compile 'net.zetetic:android-database-sqlcipher:3.5.1@aar'

```

---

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [June 29, 2016, 2:39pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/3 "2016-06-29T14:39:07Z")

</div>

Hello Developernotes,

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)

---

<div class="post-metadata">

**Author:** ![vincentskooi](https://avatars.discourse-cdn.com/v4/letter/v/50afbb/32.png) [@vincentskooi](https://discuss.zetetic.net/u/vincentskooi)\
**Post date:** [June 29, 2016, 6:07pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/4 "2016-06-29T18:07:41Z")

</div>

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’

Reference:

> **[Database Encryption for Android N: SQLCipher 3.5 - Open Source by greenrobot](https://greenrobot.org/android/database-encryption-for-android-n-sqlcipher-3-5/)**
>
> Android N: SQLCipher 3.5.0 review of changes and advantages / disadvantages for your mobile app. Examples on how SQLCipher 3.5.0 is used with Android N.

---

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [June 30, 2016, 5:10am UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/5 "2016-06-30T05:10:44Z")

</div>

> [@vincentskooi](#):
>
> greendao

I am not using **greendao** in my application

Moreover following is the dependency list from by build.gradle file

> dependencies {  
> compile project(‘:MyCustomLib’)  
> compile fileTree(include: [‘\*.jar’], dir: ‘libs’)  
> compile ‘com.google.inject:guice:4.0-beta5:no\_aop’  
> // Unit testing dependencies  
> androidTestCompile ‘junit:junit:4.12’  
> // Set this dependency if you want to use the Hamcrest matcher library  
> androidTestCompile ‘org.hamcrest:hamcrest-library:1.3’  
> // more stuff, e.g., Mockito  
> compile ‘com.android.support:design:23.3.0’  
> compile ‘com.android.support:cardview-v7:23.3.0’  
> compile ‘com.android.support:recyclerview-v7:23.3.0’  
> compile ‘com.android.support:multidex:1.0.1’  
> compile ‘com.mcxiaoke.volley:library:1.0.19’  
> compile ‘com.google.code.gson:gson:2.4’  
> compile ‘org.apache.wink.example:MultiPart:1.4’  
> compile ‘com.github.bumptech.glide:glide:3.6.1’  
> compile ‘com.google.android.gms:play-services:8.3.0’  
> compile ‘com.baoyz.swipemenulistview:library:1.3.0’  
> compile ‘com.google.android.gms:play-services-gcm:8.3.0’  
> compile ‘com.github.recruit-lifestyle:FloatingView:1.7’  
> compile(‘com.crashlytics.sdk.android:crashlytics:2.5.7@aar’) {  
> transitive = true;  
> }  
> compile(‘com.crashlytics.sdk.android:crashlytics-ndk:1.1.2@aar’) {  
> transitive = true;  
> }  
> compile ‘net.zetetic:android-database-sqlcipher:3.5.1@aar’  
> }

I can assume that the issue is of sqlcipher dependency from logcat **couldn’t find “libsqlcipher.so”**

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [June 30, 2016, 2:25pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/6 "2016-06-30T14:25:08Z")

</div>

Hi @Dinesh

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.

---

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [July 8, 2016, 5:30am UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/7 "2016-07-08T05:30:59Z")

</div>

Hi @developernotes

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.

---

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [September 5, 2016, 11:44am UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/8 "2016-09-05T11:44:56Z")

</div>

Hi @developernotes

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)

---

<div class="post-metadata">

**Author:** ![brodybits](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/brodybits/32/515_2.png) [@brodybits](https://discuss.zetetic.net/u/brodybits)\
**Post date:** [September 5, 2016, 1:07pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/9 "2016-09-05T13:07:46Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [September 5, 2016, 1:13pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/10 "2016-09-05T13:13:26Z")

</div>

Hi Brodybits,

I really appriciate for your quick response. I will be thankful of you, If can can give some idea or indication in how to rid off this situation.

---

<div class="post-metadata">

**Author:** ![brodybits](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/brodybits/32/515_2.png) [@brodybits](https://discuss.zetetic.net/u/brodybits)\
**Post date:** [September 5, 2016, 1:32pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/11 "2016-09-05T13:32:56Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [September 5, 2016, 1:48pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/12 "2016-09-05T13:48:07Z")

</div>

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.

**JAR FILES:**

> commons-lang3-3.4.jar  
> httpclient-4.5.1.jar  
> httpcore-4.4.3.jar  
> httpmime-4.3.1.jar  
> ledatastream.jar

**Gradle Dependencies**

> ```
> compile project(':MyCustomLib')
> compile fileTree(include: ['*.jar'], dir: 'libs')
> compile 'com.google.inject:guice:4.0-beta5:no_aop'
> androidTestCompile 'junit:junit:4.12'
> androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
> compile 'com.android.support:design:23.3.0'
> compile 'com.android.support:cardview-v7:23.3.0'
> compile 'com.android.support:recyclerview-v7:23.3.0'
> compile 'com.android.support:multidex:1.0.1'
> compile 'com.mcxiaoke.volley:library:1.0.19'
> compile 'com.google.code.gson:gson:2.4'
> compile 'org.apache.wink.example:MultiPart:1.4'
> compile 'com.github.bumptech.glide:glide:3.6.1'
> compile 'com.google.android.gms:play-services:8.3.0'
> compile 'com.baoyz.swipemenulistview:library:1.3.0'
> compile 'com.google.android.gms:play-services-gcm:8.3.0'
> compile 'com.github.recruit-lifestyle:FloatingView:1.7'
> compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
> transitive = true;
> }
> compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.2@aar') {
> transitive = true;
> }
> compile 'net.zetetic:android-database-sqlcipher:3.5.1@aar'
> 
> ```

---

<div class="post-metadata">

**Author:** ![brodybits](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/brodybits/32/515_2.png) [@brodybits](https://discuss.zetetic.net/u/brodybits)\
**Post date:** [September 5, 2016, 2:13pm UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/13 "2016-09-05T14:13:46Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Dinesh](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dinesh](https://discuss.zetetic.net/u/Dinesh)\
**Post date:** [September 8, 2016, 4:09am UTC](https://discuss.zetetic.net/t/sqlcipher-integration-problem/1487/14 "2016-09-08T04:09:36Z")

</div>

@Borodybits I googled to exclude usage of 64-bit library and found the solution. I used following gradle command in app gradle file’s defaultConfig:

> ndk {  
> abiFilters “armeabi”, “armeabi-v7a”, “x86”, “mips”  
> }

After this SQLCipher is working on all the devices.

Thanks a lot for you help and guidance.
