NoSuchFieldException on release.apk
sewerk opened this issue · 2 comments
- I have verified the issue exists on the latest version
- I am able to reproduce it
Version used:
1.9.1
Stack trace:
Caused by: java.lang.NoSuchFieldException: No field mMenuView in class Landroid/support/v7/widget/Toolbar; (declaration of 'android.support.v7.widget.Toolbar' appears in /data/app/com.example-1/base.apk)
at java.lang.Class.getDeclaredField(Native Method)
at com.b.a.b.a(ReflectUtil.java:27)
at com.b.a.f.c(ToolbarTapTarget.java:147)
Android version:
Nexus 5X 7.1.2
After building release apk, with proguard enabled, the private fields from support lib widgets are missing and call for ToolbarTapTarget.findOverflowView()
cause crash.
I've updated the proguard rules by adding following lines:
-keep class android.support.v7.widget.Toolbar { *** mMenuView; }
-keep class android.support.v7.widget.ActionMenuView { *** mPresenter; }
-keep class android.support.v7.widget.ActionMenuPresenter { *** mOverflowButton; }
and it is working fine now. You might want to consider adding them to documentation.
If using androidx those proguard rules change to:
-keep class androidx.appcompat.widget.Toolbar { *** mMenuView; }
-keep class androidx.appcompat.widget.ActionMenuView { *** mPresenter; }
-keep class androidx.appcompat.widget.ActionMenuPresenter { *** mOverflowButton; }