Android发行版中的SQLCipher加密错误。

时间:2017-12-19 11:19:32

标签: android encryption sqlcipher sqlcipher-android

我正在尝试使用SQLCipher加密数据库。我跟着http://lomza.totem-soft.com/tutorial-add-sqlcipher-to-your-android-app/,它工作正常,应用程序处于调试模式。但每当我尝试构建发布版本时,它都会崩溃。我甚至尝试过在每个可能的网站中提到的proguard规则。

这是我的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.**

这是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)

我正在使用compile 'net.zetetic:android-database-sqlcipher:3.5.7@aar'

0 个答案:

没有答案