Once again getting java.lang.NoClassDefFoundError: android.support.v7.internal.view.menu.i after updating to Support Tools 23
Once again getting java.lang.NoClassDefFoundError: android.support.v7.internal.view.menu.i after updating to Support Tools 23
我已经实施了 https://code.google.com/p/android/issues/detail?id=78377 for this issue with 4.2.2 phones but now that I've updated to support tools 23 the issue has come back. If you look at that issue report you'll see there are a lot of people with that same issue since updating. The solutions on NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder also don't work because they come from https://code.google.com/p/android/issues/detail?id=78377
中列出的众多解决方案之一
这是我遇到的异常:
java.lang.NoClassDefFoundError: android.support.v7.internal.view.menu.i
at android.support.v7.widget.ActionMenuView.getMenu(ActionMenuView.java:643)
at android.support.v7.widget.Toolbar.ensureMenu(Toolbar.java:876)
at android.support.v7.widget.Toolbar.getMenu(Toolbar.java:847)
at android.support.v7.internal.widget.ToolbarWidgetWrapper.getMenu(ToolbarWidgetWrapper.java:702)
at android.support.v7.internal.app.ToolbarActionBar.getMenu(ToolbarActionBar.java:583)
at android.support.v7.internal.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:441)
at android.support.v7.internal.app.ToolbarActionBar.run(ToolbarActionBar.java:65)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
at android.view.Choreographer.doCallbacks(Choreographer.java:579)
at android.view.Choreographer.doFrame(Choreographer.java:547)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5391)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(NativeStart.java)
我的混淆器有这个:
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
有什么解决办法吗?收到很多用户的投诉。
您的 ProGuard "keep class" 规则需要更新,因为目标 类 不再被混淆。在支持工具的版本 23 中,Google 将与菜单相关的 类 移出了内部包。我可以确认以下 ProGuard 规则消除了在某些三星设备上出现的 NoClassDefFoundError 运行 Android 4.2.2.
# Workaround for conflict with certain OEM-modified versions of the Android appcompat
# support libs, especially Samsung + Android 4.2.2
# See this thread for more info:
# https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=78377
-keepattributes **
# Keep all classes except the ones indicated by the patterns preceded by an exclamation mark
-keep class !android.support.v7.view.menu.**,!android.support.design.internal.NavigationMenu,!android.support.design.internal.NavigationMenuPresenter,!android.support.design.internal.NavigationSubMenu,** {*;}
# Skip preverification
-dontpreverify
# Specifies not to optimize the input class files
-dontoptimize
# Specifies not to shrink the input class files
-dontshrink
# Specifies not to warn about unresolved references and other important problems at all
-dontwarn **
# Specifies not to print notes about potential mistakes or omissions in the configuration, such as
# typos in class names or missing options that might be useful
-dontnote **
我强烈建议您使用 dex2jar 和 jd 来确认所需的混淆已经发生(此处描述:)。不幸的是,每次升级支持工具时都应该这样做,以防包被再次移动或重命名。
Google 将 类 移出了 "internal" 包,希望这样可以避免导致 NoClassDefFoundError 的类路径冲突。然而,正如 Chris Banes 在针对此错误 (https://code.google.com/p/android/issues/detail?id=78377) 的线程中所述,他们进行了 而不是 测试来验证该修复 — 此后很多人报告了同样的崩溃你看到的是:
Right, we've decided to do a one-time rename of the internal classes
which should fix this. I have done no testing on those devices
though, and don't plan on doing any either.
我已经实施了 https://code.google.com/p/android/issues/detail?id=78377 for this issue with 4.2.2 phones but now that I've updated to support tools 23 the issue has come back. If you look at that issue report you'll see there are a lot of people with that same issue since updating. The solutions on NoClassDefFoundError: android.support.v7.internal.view.menu.MenuBuilder also don't work because they come from https://code.google.com/p/android/issues/detail?id=78377
中列出的众多解决方案之一这是我遇到的异常:
java.lang.NoClassDefFoundError: android.support.v7.internal.view.menu.i
at android.support.v7.widget.ActionMenuView.getMenu(ActionMenuView.java:643)
at android.support.v7.widget.Toolbar.ensureMenu(Toolbar.java:876)
at android.support.v7.widget.Toolbar.getMenu(Toolbar.java:847)
at android.support.v7.internal.widget.ToolbarWidgetWrapper.getMenu(ToolbarWidgetWrapper.java:702)
at android.support.v7.internal.app.ToolbarActionBar.getMenu(ToolbarActionBar.java:583)
at android.support.v7.internal.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:441)
at android.support.v7.internal.app.ToolbarActionBar.run(ToolbarActionBar.java:65)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
at android.view.Choreographer.doCallbacks(Choreographer.java:579)
at android.view.Choreographer.doFrame(Choreographer.java:547)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5391)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(NativeStart.java)
我的混淆器有这个:
-keep class !android.support.v7.internal.view.menu.**,android.support.** {*;}
有什么解决办法吗?收到很多用户的投诉。
您的 ProGuard "keep class" 规则需要更新,因为目标 类 不再被混淆。在支持工具的版本 23 中,Google 将与菜单相关的 类 移出了内部包。我可以确认以下 ProGuard 规则消除了在某些三星设备上出现的 NoClassDefFoundError 运行 Android 4.2.2.
# Workaround for conflict with certain OEM-modified versions of the Android appcompat
# support libs, especially Samsung + Android 4.2.2
# See this thread for more info:
# https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=78377
-keepattributes **
# Keep all classes except the ones indicated by the patterns preceded by an exclamation mark
-keep class !android.support.v7.view.menu.**,!android.support.design.internal.NavigationMenu,!android.support.design.internal.NavigationMenuPresenter,!android.support.design.internal.NavigationSubMenu,** {*;}
# Skip preverification
-dontpreverify
# Specifies not to optimize the input class files
-dontoptimize
# Specifies not to shrink the input class files
-dontshrink
# Specifies not to warn about unresolved references and other important problems at all
-dontwarn **
# Specifies not to print notes about potential mistakes or omissions in the configuration, such as
# typos in class names or missing options that might be useful
-dontnote **
我强烈建议您使用 dex2jar 和 jd 来确认所需的混淆已经发生(此处描述:)。不幸的是,每次升级支持工具时都应该这样做,以防包被再次移动或重命名。
Google 将 类 移出了 "internal" 包,希望这样可以避免导致 NoClassDefFoundError 的类路径冲突。然而,正如 Chris Banes 在针对此错误 (https://code.google.com/p/android/issues/detail?id=78377) 的线程中所述,他们进行了 而不是 测试来验证该修复 — 此后很多人报告了同样的崩溃你看到的是:
Right, we've decided to do a one-time rename of the internal classes which should fix this. I have done no testing on those devices though, and don't plan on doing any either.