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

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

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?

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

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

since I am referencing a .so file , the official documentation says Use prebuilt libraries  |  Android NDK  |  Android Developers

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

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 and see if it makes a difference for your project.