I am trying to encrypt database using SQLCipher. I followed [http://lomza.totem-soft.com/tutorial-add-sqlcipher-to-your-android-app/][1] and it was working fine it the app is in debug mode. But whenever i try to build a release version, it crashes. I even tried proguard rules mentioned in every possible site.
Here is my progaurd
-dontwarn javax.annotation.**
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn retrofit2.**
-dontwarn com.roughike.bottombar.**
-keepclassmembers class * implements java.io.Serializable {
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-keep public enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keepnames class com.facebook.FacebookActivity
-keepnames class com.facebook.CustomTabActivity
-keep class com.facebook.all.All
-keep public class com.android.vending.billing.IInAppBillingService {
public static com.android.vending.billing.IInAppBillingService asInterface(android.os.IBinder);
public android.os.Bundle getSkuDetails(int, java.lang.String, java.lang.String, android.os.Bundle);
}
# Proguard configuration for Jackson 2.x
-keep class com.fasterxml.jackson.databind.ObjectMapper {
public <methods>;
protected <methods>;
}
-keep class com.fasterxml.jackson.databind.ObjectWriter {
public ** writeValueAsString(**);
}
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.databind.**
# For SQLCipher
-keep class net.sqlcipher.** { *; }
-dontwarn net.sqlcipher.**
And here is the logcat :
E/Database: file is encrypted or is not a database: , while compiling: select count(*) from sqlite_master;
net.sqlcipher.database.SQLiteException: file is encrypted or is not a database: , while compiling: select count(*) from sqlite_master;
at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method)
at net.sqlcipher.database.SQLiteCompiledSql.compile(Unknown Source)
at net.sqlcipher.database.SQLiteCompiledSql.<init>(Unknown Source)
at net.sqlcipher.database.SQLiteProgram.<init>(Unknown Source)
at net.sqlcipher.database.SQLiteQuery.<init>(Unknown Source)
at net.sqlcipher.database.SQLiteDirectCursorDriver.query(Unknown Source)
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(Unknown Source)
at net.sqlcipher.database.SQLiteDatabase.rawQuery(Unknown Source)
at net.sqlcipher.database.SQLiteDatabase.keyDatabase(Unknown Source)
at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(Unknown Source)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(Unknown Source)
at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(Unknown Source)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(Unknown Source)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(Unknown Source)
at im.gcom.runtime.android.p.c(Unknown Source)
at im.gcom.runtime.android.p.a(Unknown Source)
at im.gcom.runtime.af.a(Unknown Source)
at im.gcom.core.modules.x.a.<init>(Unknown Source)
at im.gcom.core.modules.q.a(Unknown Source)
at im.gcom.core.modules.b.a.c(Unknown Source)
at im.gcom.core.modules.q.z(Unknown Source)
at im.gcom.core.r.<init>(Unknown Source)
at im.gcom.core.a.<init>(Unknown Source)
at im.gcom.sdk.b.b(Unknown Source)
at im.gcom.sdk.d.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
I am using compile 'net.zetetic:android-database-sqlcipher:3.5.7@aar'
[1]: http://lomza.totem-soft.com/tutorial-add-sqlcipher-to-your-android-app/