缩小资源并应用proguard规则后,Android应用程序崩溃

时间:2018-03-07 10:57:11

标签: android proguard

发布版本的封闭代码之后。应用程序崩溃,出现以下错误。我在proguard-rules.po文件中保留了android支持库和网络类,但它在启动应用程序时给出了运行时异常。

    java.lang.RuntimeException: Unable to instantiate application com.App: java.lang.RuntimeException: Stub!
                                                         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.RuntimeException: Stub!
                                                         at android.content.i.<init>(SourceFile:4)
                                                         at android.content.j.<init>(SourceFile:5)
                                                         at android.app.e.<init>(SourceFile:6)                                                           at com..App.<init>(SourceFile:21)
                                                         at java.lang.Class.newInstance(Native Method)
                                                         at android.app.Instrumentation.newApplication(Instrumentation.java:1007)
                                                         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) 

以下是我在保留类应用程序中应用的规则。

 > -keepattributes SourceFile,LineNumberTable
    > -renamesourcefileattribute SourceFile
    > 
    > ####### ButterKnife ########
    > 
    > # Retain generated class which implement ViewBinder.
    > -keep public class * implements butterknife.internal.ViewBinder { public <init>(); }
    > 
    > # Prevent obfuscation of types which use ButterKnife annotations since the simple name
    > # is used to reflectively look up the generated ViewBinder.
    > -keep class butterknife.*
    > -keepclasseswithmembernames class * { @butterknife.* <methods>; }
    > -keepclasseswithmembernames class * { @butterknife.* <fields>; }
    > 
    > -dontwarn butterknife.internal.Utils
    > 
    > ####### Crashlytics 2.+ #######
    > 
    > -keep class com.crashlytics.** { *; }
    > -keep class com.crashlytics.android.**
    > 
    > -keepattributes SourceFile, LineNumberTable, *Annotation*
    > 
    > -printmapping mapping.txt
    > 
    > -keep public class * extends java.lang.Exception
    > 
    > ####### Retrofit ########
    > 
    > -dontwarn retrofit2.**
    > -keep class retrofit2.** { *; }
    > -keepattributes Signature
    > -keepattributes Exceptions
    > 
    > -keepclasseswithmembers class * {
    >     @retrofit2.http.* <methods>; }
    > 
    > -dontwarn okhttp3.**
    > 
    > -dontwarn okio.**
    > 
    > ####### GSON ########
    > 
    > -keepattributes EnclosingMethod
    > 
    > # Gson specific classes
    > -keep class sun.misc.Unsafe { *; }
    > -keep class com.google.gson.stream.** { *; }
    > 
    > ####### Eventbus ########
    > 
    > -keepattributes *Annotation*
    > -keepclassmembers class ** {
    >     @org.greenrobot.eventbus.Subscribe <methods>; }
    > -keep enum org.greenrobot.eventbus.ThreadMode { *; }
    > 
    > # Only required if you use AsyncExecutor
    > -keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    >     <init>(java.lang.Throwable); }
    > 
    > 
    > # firebase
    > -dontwarn com.google.firebase.**
    > 
    > #OSMDroid
    > -dontwarn org.osmdroid.**
    > -dontwarn com.github.mikephil.charting.charts.**
    > 
    > -dontwarn android.**
    > #-keep public class * extends android.app.Activity
    > #-keep public class * extends android.app.Application
    > 
    > 
    > ####### Support Libraries ########
    > 
    > -dontwarn android.support.design.**
    > -keep class android.support.design.** { *; }
    > -keep interface android.support.design.** { *; }
    > -keep public class android.support.design.R$* { *; }
    > 
    > -dontwarn android.support.v7.**
    > -keep class android.support.v7.** { *; }
    > -keep interface android.support.v7.** { *; }
    > 
    > -dontwarn android.support.v4.**
    > -keep class android.support.v4.** { *; }
    > -keep interface android.support.v4.** { *; }
    > 
    > -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 public class * extends android.support.v4.view.ActionProvider {
    >     public <init>(android.content.Context); }
    > 
    > 
    > -dontwarn org.apache.log4j.**
    > -dontwarn javax.servlet.**
    > -dontwarn org.xml.sax.**
    > -dontwarn org.apache.log.**
    > -dontwarn org.apache.avalon.**
    > 
    > -dontwarn org.apache.commons.**
    > -keep class org.apache.http.** { *; }
    > -dontwarn org.apache.http.**
    > 
    > -keep class android.support.v7.internal.** { *; }
    > -keep interface android.support.v7.internal.** { *; }

0 个答案:

没有答案