启用 proguard,我的构建版本应用程序不会再次安装
Posted
技术标签:
【中文标题】启用 proguard,我的构建版本应用程序不会再次安装【英文标题】:Enabled proguard, My build release app won't install again 【发布时间】:2016-11-19 07:05:08 【问题描述】:我启用了 proguard 来缩小我的发布 apk。但在那之后我的应用程序不会安装。如果我能得到一些关于如何修复它的帮助,我会很高兴。它似乎无法在我正在使用的应用程序主题引擎库中找到方法。
androidRuntime: FATAL EXCEPTION: main
Process: com.example.john.music, PID: 8076
java.lang.RuntimeException: Failed to get ActionView from an ActionMenuItemView: mItemData
at com.afollestad.appthemeengine.inflation.a.i(Unknown Source)
at com.afollestad.appthemeengine.inflation.a.h(Unknown Source)
at com.afollestad.appthemeengine.inflation.a.setIcon(Unknown Source)
at android.support.v7.view.menu.ActionMenuItemView.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.view.menu.d.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.view.menu.i.j(Unknown Source)
at android.support.v7.view.menu.d.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.view.menu.i.d(Unknown Source)
at android.support.v7.view.menu.i.a(Unknown Source)
at android.support.v7.view.menu.i.h(Unknown Source)
at android.support.v7.a.bj.j(Unknown Source)
at android.support.v7.a.bk.run(Unknown Source)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:559)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6117)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.NoSuchFieldException: mItemData
at java.lang.Class.getDeclaredField(Class.java:929)
at com.afollestad.appthemeengine.inflation.a.i(Unknown Source)
at com.afollestad.appthemeengine.inflation.a.h(Unknown Source)
at com.afollestad.appthemeengine.inflation.a.setIcon(Unknown Source)
at android.support.v7.view.menu.ActionMenuItemView.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.view.menu.d.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.view.menu.i.j(Unknown Source)
at android.support.v7.view.menu.d.a(Unknown Source)
at android.support.v7.widget.k.a(Unknown Source)
at android.support.v7.view.menu.i.d(Unknown Source)
at android.support.v7.view.menu.i.a(Unknown Source)
at android.support.v7.view.menu.i.h(Unknown Source)
at android.support.v7.a.bj.j(Unknown Source)
at android.support.v7.a.bk.run(Unknown Source)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:559)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6117)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
【问题讨论】:
【参考方案1】:解决了。我找到了一个可行的解决方案:How to make Proguard ignore external libraries?。我将此添加到我的 proguard 文件中:
-keep class javax.** *;
-keep class org.** *;
-keep class com.afollestad.** *;
最后一个最重要,是整个主题库,有些类找不到。
【讨论】:
以上是关于启用 proguard,我的构建版本应用程序不会再次安装的主要内容,如果未能解决你的问题,请参考以下文章
为啥我的 Xamarin.Android 项目不能在启用 Proguard 的情况下构建:“java.exe”退出代码 1
错误 MSB6006:启用 ProGuard 时“java.exe”以代码 1 退出