4.5.5 - migration to new lib results in crashes in minified builds

I’m upgrading an app from the legacy android library to the new one, that uses proguard.

We replaced proguard rules:

# sqlcipher
-keep class net.sqlcipher.** { *; }
-keep class net.sqlcipher.database.* { *; }

with

keep class net.zetetic.database.** { *; }
-keep class net.zetetic.database.sqlcipher.** { *; }

We’ve also added System.loadLibrary("sqlcipher") in our Application.onCreate()

This works fine, and dbs are encrypted normally in our debug builds, however in our minified/proguarded release builds, we are getting crashes:

Fatal Exception: java.lang.UnsatisfiedLinkError: No implementation found for long net.zetetic.database.sqlcipher.SQLiteConnection.nativeOpen(java.lang.String, int, java.lang.String, boolean, boolean) (tried Java_net_zetetic_database_sqlcipher_SQLiteConnection_nativeOpen and Java_net_zetetic_database_sqlcipher_SQLiteConnection_nativeOpen__Ljava_lang_String_2ILjava_lang_String_2ZZ) - is the library loaded, e.g. System.loadLibrary?
       at net.zetetic.database.sqlcipher.SQLiteConnection.nativeOpen(SourceFile)
       at net.zetetic.database.sqlcipher.SQLiteConnection.open(SourceFile:5)
       at net.zetetic.database.sqlcipher.SQLiteConnection.open(SourceFile:2)
       at net.zetetic.database.sqlcipher.SQLiteConnectionPool.openConnectionLocked(:6)
       at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SourceFile:4)
       at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SourceFile:2)
       at net.zetetic.database.sqlcipher.SQLiteDatabase.openInner(:5)
       at net.zetetic.database.sqlcipher.SQLiteDatabase.open()
       at net.zetetic.database.sqlcipher.SQLiteDatabase.openDatabase(SourceFile:7)
       at net.zetetic.database.sqlcipher.SQLiteOpenHelper.getDatabaseLocked(:131)
       at net.zetetic.database.sqlcipher.SQLiteOpenHelper.getWritableDatabase(SourceFile:3)
       at net.zetetic.database.sqlcipher.SupportHelper.getWritableDatabase(:2)
       at androidx.room.f0.z(:4)
       at androidx.room.f0.d()
       at androidx.room.f0.K(:8)
       at th.a.y1(:11)
       at com.core.datastore.cad.dao.p$e.a(:9)
       at com.core.datastore.cad.dao.p$e.call()
       at androidx.room.i.invokeSuspend(:9)
       at cn.a.resumeWith(:7)
       at tn.j0.run(:113)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
       at java.lang.Thread.run(Thread.java:1012)

Is there something missing from our proguard config?

There’s an open issue for this crash here:

Hi @mandrachek,

Can you run apktool [1] against your release build to see if the libsqlcipher.so is being included for the respective platforms? Are you generating an APK, or AAB file?


  1. https://apktool.org ↩︎

Hey Nick. We release AAB’s to the play store, but we generate and test APK files before releasing. This is occurring with our APK files. I can open the apk in android studio, and /lib/arm64-v8a/libsqlcipher.so is present (we only support arm64-v8a ABI).

Not sure why, but this is failing even with minification disabled in our release builds. But it works sometimes, for a little while… and then eventually we get this crash.