# Latest version 3.5.8 used by means of the native file libsqlcipher.so doesn't find "net.sqlcipher.database.SQLiteDatabase" class

**URL:** <https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556>\
**Category:** Issues\
**Created:** [December 28, 2017, 4:37pm UTC](https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556 "2017-12-28T16:37:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![raulh](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/raulh/32/741_2.png) [@raulh](https://discuss.zetetic.net/u/raulh)\
**Post date:** [December 28, 2017, 4:37pm UTC](https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556/1 "2017-12-28T16:37:26Z")

</div>

_SQLCipher for Android version:_  
_v3.5.8_

Previously we used _v3.4.0_, however, since Google has announced a security update for next August 2018, we are trying to migrate as soon as possible to targetSDK 26, and this version wasn’t supporting Android N, therefore we thought moving to 3.5.8 is the right decision. However this version crashes after setting up sqlcipher for Android and trying to be loaded from a static initialiser. Read the following:

**Expected Behavior**  
Latest version _3.5.8_ used by means of the compiled file [libsqlcipher.so](http://libsqlcipher.so) from Native land should work normally when loading its .so file at the Android land.

**Actual Behavior**  
Crashes with crash:  
`12-28 12:17:42.139 10121-10156/? A/zygote: thread.cc:2090] No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "net.sqlcipher.database.SQLiteDatabase" on path: DexPathList[[zip file "/data/app/com.xxx.xxxx-5spNAiLRX4TIB7jBRnwGkA==/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxxx-5spNAiLRX4TIB7jBRnwGkA==/lib/arm, /data/app/xxx.xxx.xxx-5spNAiLRX4TIB7jBRnwGkA==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]`

**Steps to Reproduce**  
The library is required at our project to be used as a .so file since it’s used by other libraries like odb 2.4.  
Proguard was used as suggested at a previous issue like:  
`-keep class net.sqlcipher.** { *; }`  
but both with and without proguard this doesn’t work. Proguard is at the build.gradle from the app, buildType release

[Android.mk](http://Android.mk) has included  
`LOCAL_SHARED_LIBRARIES += sqlcipher`  
with the reference to that file:  
`LOCAL_MODULE := sqlcipher LOCAL_SRC_FILES := $(ROOT_PATH)/../../android-database-sqlcipher/android-database-sqlcipher/src/main/libs/$(TARGET_ARCH_ABI)/sqlcipher.so`

and loads it by means of:

`static { System.loadLibrary("c++_shared"); System.loadLibrary("sqlcipher"); }`  
The Android project launches the app, and tries to load this sqlciphe\_android.so file, and fails crashing.

---

<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:** [December 28, 2017, 11:06pm UTC](https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556/2 "2017-12-28T23:06:15Z")

</div>

Hi @raulh

We switched from `stlport_shared` to `stlport_static` between 3.4.0 and 3.5.8. I wonder if that is a cause of your issue? Are you using the commercial, or community edition of SQLCipher for Android?

---

<div class="post-metadata">

**Author:** ![raulh](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/raulh/32/741_2.png) [@raulh](https://discuss.zetetic.net/u/raulh)\
**Post date:** [December 29, 2017, 3:15pm UTC](https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556/3 "2017-12-29T15:15:45Z")

</div>

SQLCipher Community Edition since it’s the one provided at the github repo, isn’t?

> **[sqlcipher/android-database-sqlcipher](https://github.com/sqlcipher/android-database-sqlcipher)**
>
> Android SQLite API based on SQLCipher. Contribute to sqlcipher/android-database-sqlcipher development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![raulh](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/raulh/32/741_2.png) [@raulh](https://discuss.zetetic.net/u/raulh)\
**Post date:** [December 29, 2017, 3:44pm UTC](https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556/4 "2017-12-29T15:44:52Z")

</div>

this can’t be changed: `LOCAL_SHARED_LIBRARIES += sqlcipher`  
since this points to a .so file compiled from your instructions being the resulting  
[libsqlcipher.so](http://libsqlcipher.so)

---

<div class="post-metadata">

**Author:** ![raulh](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/raulh/32/741_2.png) [@raulh](https://discuss.zetetic.net/u/raulh)\
**Post date:** [December 29, 2017, 3:57pm UTC](https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556/5 "2017-12-29T15:57:34Z")

</div>

since I am referencing a .so file , the official documentation says [Use prebuilt libraries &nbsp;|&nbsp; Android NDK &nbsp;|&nbsp; Android Developers](https://developer.android.com/ndk/guides/prebuilts.html)

> Include PREBUILT\_SHARED\_LIBRARY or PREBUILT\_STATIC\_LIBRARY, depending on whether you are using a shared (.so) or static (.a) library. This means I should include it as I did first:

`LOCAL_MODULE := sqlcipher_android LOCAL_SRC_FILES := $(ROOT_PATH)/../../thirdparty/android-database-sqlcipher/android-database-sqlcipher/src/main/libs/$(TARGET_ARCH_ABI)/libsqlcipher.so`

`include $(PREBUILT_STATIC_LIBRARY)`

and at the end of Android.mk  
`LOCAL_SHARED_LIBRARIES += sqlcipher_android`

---

<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:** [December 29, 2017, 4:19pm UTC](https://discuss.zetetic.net/t/latest-version-3-5-8-used-by-means-of-the-native-file-libsqlcipher-so-doesnt-find-net-sqlcipher-database-sqlitedatabase-class/2556/6 "2017-12-29T16:19:28Z")

</div>

Hi @raulh

I’m sorry if I was unclear. I was suggesting that you change the SQLCipher for Android build to utilize `stlport_shared`, also include the new loading for that [here](https://github.com/sqlcipher/android-database-sqlcipher/blob/master/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabase.java#L230) and see if it makes a difference for your project.
