SQLCipher在签名发布APK中导致Android崩溃

时间:2016-03-09 19:59:21

标签: android sqlcipher sqlcipher-android

我在Android项目中使用SQLCipher。一切都运行良好的测试,但每当我构建一个签名版本APK并安装它我收到以下错误,并在我打电话时崩溃

SQLCipher.loadLibs(context);

这是崩溃

03-09 14:47:45.833 24895-24895/? E/Database: Can't find SQLiteDatabase.mNativeHandle
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143] No pending exception expected: java.lang.NoSuchFieldError: no "I" field "mNativeHandle" in class "Lnet/sqlcipher/database/SQLiteDatabase;" or its superclasses
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String) (Runtime.java:-2)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at java.lang.String java.lang.Runtime.doLoad(java.lang.String, java.lang.ClassLoader) (Runtime.java:428)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void java.lang.Runtime.loadLibrary(java.lang.String, java.lang.ClassLoader) (Runtime.java:369)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void java.lang.System.loadLibrary(java.lang.String) (System.java:988)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void net.sqlcipher.database.SQLiteDatabase.a(android.content.Context, java.io.File) ((null):-1)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void net.sqlcipher.database.SQLiteDatabase.a(android.content.Context) ((null):-1)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void com.myapp.BBISDK.ax.o() ((null):-1)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void com.myapp.BBISDK.ax.<init>(java.lang.Integer, com.myapp.BBISDK.d.a, android.app.Activity) ((null):-1)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at com.myapp.BBISDK.ax com.myapp.BBISDK.ax.a(java.lang.Integer, com.myapp.BBISDK.d.a, android.app.Activity) ((null):-1)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void com.myapp.myapp.LoginActivity.onCreate(android.os.Bundle) ((null):-1)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:5990)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1106)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2278)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2387)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.app.ActivityThread.access$800(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:151)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1303)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.os.Looper.loop() (Looper.java:135)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:5254)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[], boolean) (Method.java:-2)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:372)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:903)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143]   at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:698)
03-09 14:47:45.834 24895-24895/? A/art: art/runtime/thread.cc:1143] 
03-09 14:47:45.965 24895-24895/? A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x203a79ac in tid 24895 (kit.myapp)
 03-09 14:47:45.965 24895-24895/? I/libc: Suppressing debuggerd output because prctl(PR_GET_DUMPABLE)==0

我在调试中运行应用程序时收到类似的错误,但它不会导致崩溃。

这里任何方向都会很棒。感谢。

2 个答案:

答案 0 :(得分:3)

我在我的proguard文件中对此进行了修复

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

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

答案 1 :(得分:0)

当你从debug转移到release版本时,你开始获得NoSuchFieldError或类似的“嘿,这个东西就丢失了!”错误,首先转到ProGuard设置。如果类或包的-keep清除了问题,那么您至少有一个权宜之计解决方案。但是,您可以添加TODO项来提供更精细的解决方案。