Implement SQLcipher in to a app with few modules

I am trying to encrypt my database using SQLcipher. In my app there are three separate modules(Main app has dependencies to these modules). Database part is done in a separate module(Not in the app module). I have followed the instructions and my code build successfully.
But my app crashes when I try to call “SQLiteDatabase.loadLibs(context)”.
Error massage is “java.lang.UnsatisfiedLinkError: Couldn’t load stlport_shared from loader dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.stl.blelogger-1.apk”],nativeLibraryDirectories=[/data/app-lib/com.stl.blelogger-1, /vendor/lib, /system/lib]]]: findLibrary returned null” .

I have added all the libraries in to the module where I develop the database(Not to the main app module).

Can any one help me to fix this…

Thanks.

Hello @sachithmsw

It appears that the native libraries (i.e., .so files) are not being bundled within your application during compilation. Can you review your project configuration and see if you can make the appropriate adjustments?

1 Like

In particular:

  • Use the AAR if you are building with Android Studio
  • Do not use the 1.5.0-beta2 edition of the Play Services Gradle plugin, as it screws up native binaries coming from AARs (1.5.0 is out, apparently, and does not have this bug)
1 Like

Hi, Thanks for the reply. Please see this image. I have added .so files to my project.

Main activity is in app module. Database is handled in datastore module.

Since you are using Android Studio, words cannot express how strongly I recommend that you switch to using the AAR, rather than trying to manually integrate the various files:

compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar'

1 Like

Hi, Thank you for your comment.
Could you please tell me how to use AAR or derect me to a good tutorial.

Thanks.

You use it the same way that you use appcompat-v7, support-v4, or lots of other dependencies with Android Studio. In your module’s build.gradle file, list SQLCipher for Android as a dependency.

For example, this sample app has:

dependencies {
  compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar'
}

Thank you very much…