使用ProGuard时应用程序崩溃

时间:2017-03-30 06:52:18

标签: android proguard

当启用ProGuard来混淆我的代码时,它会崩溃我的应用程序。没有ProGuard,它运行良好。我添加了minifyEnabled trueshrinkResources true。我还需要添加更多规则吗?

这是我的proguard-rules.pro

-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn retrofit2.**
-dontwarn android.support.design.**

-keepattributes *Annotation*,Signature,Exceptions

-keep class retrofit2.** { *; }
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }
-keep class android.support.v7.widget.RoundRectDrawable { *; }

-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}
-keep public class * extends android.support.v4.view.ActionProvider {
    public <init>(android.content.Context);
}

以下是我在我的应用中使用的库:

dependencies {
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
compile "com.android.support:design:$supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
compile "com.android.support:cardview-v7:$supportLibraryVersion"
compile "com.android.support:customtabs:$supportLibraryVersion"
compile "com.android.support:palette-v7:$supportLibraryVersion"

compile "com.google.firebase:firebase-auth:$firebaseVersion"
compile "com.google.firebase:firebase-database:$firebaseVersion"
compile "com.google.firebase:firebase-core:$firebaseVersion"
compile "com.google.firebase:firebase-crash:$firebaseVersion"
compile "com.google.firebase:firebase-messaging:$firebaseVersion"
compile "com.google.firebase:firebase-ads:$firebaseVersion"

compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"

compile 'com.squareup.picasso:picasso:2.5.2'

compile 'com.github.chrisbanes:PhotoView:1.3.1'

compile 'com.journeyapps:zxing-android-embedded:3.4.0'
}

编辑:Stacktrace:

E/UncaughtException: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object[] java.util.Collection.toArray()' on a null object reference
                                                                  at java.util.ArrayList.addAll(ArrayList.java:188)
                                                                  at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(Unknown Source)
                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5461)
                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

0 个答案:

没有答案