0

已经尝试了包中的所有技巧,但无法弄清楚缺少什么。调试构建运行良好,但发布构建一旦启动就会失败。

我想,异常 - “引起:java.lang.IllegalStateException:无效的 UTF-16 代码点”是导致崩溃的原因,但是它在调试版本中如何正常工作?这让我很困惑。

是的,我已经解决了这里的大部分问题,但似乎没有一个可以解决我的问题。请求具有专业知识的人在这里提供帮助..

这是来自 adb 的崩溃日志 -

02-28 04:37:53.298 11467-11467/? E/a: E --- a --- 生成密钥时出现意外错误

                                          at javax.crypto.SecretKeyFactory.generateSecret(SecretKeyFactory.java:474)
                                          at com.sample.android.database.a.a(SourceFile:67)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
                                          at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
                                          at com.sample.android.database.a.a(SourceFile:71)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
                                          at com.sample.android.database.a.a(SourceFile:53)
02-28 04:37:53.299 11467-11467/? E/a:     at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
                                          at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
                                          at com.sample.android.database.a.a(SourceFile:71)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
                                          at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
                                          at com.sample.android.database.a.a(SourceFile:71)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
02-28 04:37:53.299 11467-11467/? E/a:     at com.sample.android.database.a.a(SourceFile:71)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
                                          at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
02-28 04:37:53.299 11467-11467/? E/a:     at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
                                          at com.sample.android.database.a.a(SourceFile:71)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
                                          at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
                                          at com.sample.android.Applicationsample.attachBaseContext(SourceFile:108)
                                          at android.app.Application.attach(Application.java:189)
02-28 04:37:53.300 11467-11467/? E/a:     at android.app.Instrumentation.newApplication(Instrumentation.java:1008)
                                          at android.app.Instrumentation.newApplication(Instrumentation.java:992)
                                          at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
                                          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
                                          at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                          at android.os.Looper.loop(Looper.java:154)
                                          at android.app.ActivityThread.main(ActivityThread.java:6119)
                                          at java.lang.reflect.Method.invoke(Native Method)
                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                      java.security.spec.InvalidKeySpecException: Could not generate secret key
                                          at javax.crypto.SecretKeyFactory.generateSecret(SecretKeyFactory.java:474)
                                          at com.sample.android.database.a.a(SourceFile:67)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
                                          at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
                                          at com.sample.android.database.a.a(SourceFile:71)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.e.c.b(SourceFile:1105)
02-28 04:37:53.304 11467-11467/? E/a:     at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:83)
                                          at com.sample.android.database.a.a(SourceFile:71)
                                          at com.sample.android.database.a.a(SourceFile:53)
                                          at com.sample.android.database.a.a(SourceFile:88)
                                          at com.sample.android.e.c.n(SourceFile:1110)
                                          at com.sample.android.database.a.a.c.a(SourceFile:52)
                                          at com.sample.android.c.a.a(SourceFile:32)
                                          at com.sample.android.Applicationsample.attachBaseContext(SourceFile:108)
                                          at android.app.Application.attach(Application.java:189)
                                          at android.app.Instrumentation.newApplication(Instrumentation.java:1008)
                                          at android.app.Instrumentation.newApplication(Instrumentation.java:992)
                                          at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
                                          at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
                                          at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                          at android.os.Looper.loop(Looper.java:154)
                                          at android.app.ActivityThread.main(ActivityThread.java:6119)
                                          at java.lang.reflect.Method.invoke(Native Method)
                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                       Caused by: java.lang.IllegalStateException: invalid UTF-16 codepoint
                                          at com.android.org.bouncycastle.util.Strings.toUTF8ByteArray(Strings.java:177)
                                          at com.android.org.bouncycastle.util.Strings.toUTF8ByteArray(Strings.java:132)
                                          at com.android.org.bouncycastle.crypto.PBEParametersGenerator.PKCS5PasswordToUTF8Bytes(PBEParametersGenerator.java:135)
                                          at com.android.org.bouncycastle.jcajce.provider.symmetric.util.PBE$Util.convertPassword(PBE.java:438)
                                          at com.android.org.bouncycastle.jcajce.provider.symmetric.util.PBE$Util.makePBEMacParameters(PBE.java:349)
                                          at com.android.org.bouncycastle.jcajce.provider.digest.SHA1$BasePBKDF2WithHmacSHA1.engineGenerateSecret(SHA1.java:141)
                                          at javax.crypto.SecretKeyFactory.generateSecret(SecretKeyFactory.java:463)
                                            ... 826 more
02-28 04:37:53.324 11467-11467/? D/AndroidRuntime: Shutting down VM


                                                   --------- beginning of crash
02-28 04:37:53.331 11467-11467/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.sample.android, PID: 11467
                                                   java.lang.RuntimeException: Unable to instantiate application com.sample.android.Applicationsample: java.lang.NullPointerException: Attempt to get length of null array
                                                       at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
                                                       at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6119)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                                    Caused by: java.lang.NullPointerException: Attempt to get length of null array
                                                       at android.util.Base64.encode(Base64.java:494)
                                                       at android.util.Base64.encodeToString(Base64.java:456)
                                                       at com.sample.android.database.a.a(SourceFile:87)
                                                       at com.sample.android.e.c.n(SourceFile:1110)
                                                       at com.sample.android.e.c.b(SourceFile:1105)
                                                       at com.sample.android.database.a.a.c.a(SourceFile:52)
                                                       at com.sample.android.c.a.a(SourceFile:83)
                                                       at com.sample.android.database.a.a(SourceFile:88)
                                                       at com.sample.android.e.c.n(SourceFile:1110)
                                                       at com.sample.android.e.c.b(SourceFile:1105)
                                                       at com.sample.android.database.a.a.c.a(SourceFile:52)
                                                       at com.sample.android.c.a.a(SourceFile:83)
                                                       at com.sample.android.database.a.a(SourceFile:71)
                                                       at com.sample.android.database.a.a(SourceFile:53)
                                                       at com.sample.android.database.a.a(SourceFile:88)
                                                       at com.sample.android.e.c.n(SourceFile:1110)
                                                       at com.sample.android.e.c.b(SourceFile:1105)
                                                       at com.sample.android.database.a.a.c.a(SourceFile:52)
                                                       at com.sample.android.c.a.a(SourceFile:32)
                                                       at com.sample.android.Applicationsample.attachBaseContext(SourceFile:108)
                                                       at android.app.Application.attach(Application.java:189)
                                                       at android.app.Instrumentation.newApplication(Instrumentation.java:1008)
                                                       at android.app.Instrumentation.newApplication(Instrumentation.java:992)
                                                       at android.app.LoadedApk.makeApplication(LoadedApk.java:796)
                                                        ... 9 more
02-28 04:37:53.349 11467-11467/? D/Error: ERR: exClass=java.lang.NullPointerException
02-28 04:37:53.349 11467-11467/? D/Error: ERR: exMsg=Attempt to get length of null array
02-28 04:37:53.349 11467-11467/? D/Error: ERR: file=Base64.java
02-28 04:37:53.349 11467-11467/? D/Error: ERR: class=android.util.Base64
02-28 04:37:53.349 11467-11467/? D/Error: ERR: method=encode line=494
02-28 04:37:53.349 11467-11467/? D/Error: ERR: stack=java.lang.RuntimeException: Unable to instantiate application com.sample.android.Applicationsample: java.lang.NullPointerException: Attempt to get length of null array
                                              at android.app.LoadedApk.makeApplication(LoadedApk.java:802)
                                              at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5377)
                                              at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                              at android.os.Looper.loop(Looper.java:154)
                                              at android.app.ActivityThread.main(ActivityThread.java:6119)
                                              at java.lang.reflect.Method.invoke(Native Method)
                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                                           Caused by: java.lang.NullPointerException: Attempt to get length of null array
                                              at android.util.Base64.encode(Base64.java:494)
                                              at android.util.Base64.encodeToString(Base64.java:456)
                                              at com.sample.android.database.a.a(SourceFile:87)
                                              at com.sample.android.e.c.n(SourceFile:1110)
                                              at com.sample.android.e.c.b(SourceFile:1105)
                                              at com.sample.android.database.a.a.c.a(SourceFile:52)
                                              at com.sample.android.c.a.a(SourceFile:83)
                                              at com.sample.android.database.a.a(SourceFile:71)
                                              at com.sample.android.database.a.a(SourceFile:53)
                                              at com.sample.android.e.c.n(SourceFile:1110)
                                              at com.sample.android.e.c.b(SourceFile:1105)
                                              at com.sample.android.database.a.a.c.a(SourceFile:52)
                                              at com.sample.android.c.a.a(SourceFile:83)
                                              at com.sample.android.database.a.a(SourceFile:71)
                                              at com.sample.android.database.a.a(SourceFile:53)
                                              at com.sample.android.database.a.a(SourceFile:88)
                                              at com.sample.android.e.c.n(SourceFile:1110)
                                              at com.sample.android.e.c.b(SourceFile:1105)
                                              at com.sample.android.database.a.a.c.a(SourceFile:52)
                                              at com.sample.android.c.a.a(SourceFile:83)
                                            at c
02-28 04:37:53.349 11467-11467/? D/Error: ERR: TOTAL BYTES WRITTEN: 41256
02-28 04:37:53.350 902-20335/? W/ActivityManager:   Force finishing activity com.sample.android/.activities.Activitysample

下面是proguard文件 - “proguard-rules.pro” -

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application

-dontwarn javax.annotation.**

-dontwarn android.app.**
-dontwarn android.support.**
-dontwarn android.view.**
-dontwarn android.widget.**

-dontwarn com.google.common.primitives.**

-dontwarn **CompatHoneycomb
-dontwarn **CompatHoneycombMR2
-dontwarn **CompatCreatorHoneycombMR2

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

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

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    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();
}

-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated, SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
    native <methods>;
}

-keep public class javax.crypto.spec.** {
  public protected *;
}

# Class names are needed in reflection
-keepnames class com.amazonaws.**
# Request handlers defined in request.handlers
-keep class com.amazonaws.services.**.*Handler
# The following are referenced but aren't required to run
-dontwarn com.fasterxml.jackson.**
-dontwarn org.apache.commons.logging.**
# Android 6.0 release removes support for the Apache HTTP client
-dontwarn org.apache.http.**
# The SDK has several references of Apache HTTP client
-dontwarn com.amazonaws.http.**
-dontwarn com.amazonaws.metrics.**

    enter code here
4

1 回答 1

0

在您的 Proguard 文件中添加这些行

#### -- Sql Cipher --
-keep  class net.sqlcipher.** {
    *;
}

-keep  class net.sqlcipher.database.** {
    *;
}
于 2017-03-14T13:07:13.513 回答