proguard – 在proguard / minify之后,AppCompat不支持当前的主题function

在构建应用程序(使用minifyEnabled为true)之后,我已经从v22.2.1更新了支持库到v23.0.0我有“AppCompat不支持当前主题function”的例外:

08-23 05:46:10.168 19437 19437 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{tm.alashow.dotjpg/tm.alashow.dotjpg.ui.activity.MainActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features 08-23 05:46:10.168 19437 19437 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417) 08-23 05:46:10.168 19437 19437 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477) 08-23 05:46:10.168 19437 19437 E AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java) 08-23 05:46:10.168 19437 19437 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345) 

调试应用程序或禁用proguard(minifyEnabled false)时,exception不会抛出。 仅在启用proguard时才会抛出。

主题:

  @color/primary @color/primary_dark ...  

Proguard文件:

 -dontwarn android.support.v7.** -keep class android.support.v7.** { *; } -keep interface android.support.v7.** { *; } -keep class android.support.design.widget.** { *; } -keep interface android.support.design.widget.** { *; } -dontwarn android.support.design.** -keep public class * extends android.support.design.widget.CoordinatorLayout$Behavior { public (android.content.Context, android.util.AttributeSet); } 

我已经尝试过这个问题的答案: 升级到AppCompat v22.1.0并且现在获得IllegalArgumentException:AppCompat不支持当前的主题function ,我认为这不是重复的问题。

我该如何解决? 当然,启用proguard

错误消息可能会产生误导。 留意这样的Proguard警告:

 Warning: org.acra.ErrorReporter: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification Warning: there were 1 unresolved references to library class members. You probably need to update the library versions. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember) Exception while processing task java.io.IOException: Please correct the above warnings first. at proguard.Initializer.execute(Initializer.java:473) at proguard.ProGuard.initialize(ProGuard.java:233) at proguard.ProGuard.execute(ProGuard.java:98) at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074) at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139) at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115) at com.android.builder.tasks.Job.runTask(Job.java:48) at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227) at java.lang.Thread.run(Thread.java:745) 

虽然如果存在来自先前构建的classes.jar文件,则构建将成功发生错误,但干净构建将按预期失败。

在我的情况下,修复Proguard警告也删除了AppCompatexception。