I generated release build by enabling minifyEnabled property and when I try to run the release build, it force closes with following log. Please help me to debug it
java.lang.NullPointerException
at MYPACKAGENAME.MainActivity.onCreateOptionsMenu(Unknown Source)
at android.app.Activity.onCreatePanelMenu(Activity.java:2538)
at android.support.v4.app.i.onCreatePanelMenu(Unknown Source)
at android.support.v7.internal.view.j.onCreatePanelMenu(Unknown Source)
at android.support.v7.app.ac.onCreatePanelMenu(Unknown Source)
at android.support.v7.internal.view.j.onCreatePanelMenu(Unknown Source)
at android.support.v7.internal.a.b.f(Unknown Source)
at android.support.v7.internal.a.b$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
This is my code for method onCreateOptionsMenu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
//Set up ShareActionProvider's default share intent
MenuItem shareItem = menu.findItem(R.id.action_share_main);
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
mShareActionProvider.setShareIntent(getDefaultIntent());
return super.onCreateOptionsMenu(menu);
}
The problem is that ShareActionProvider
is being stripped/obfuscated, but the support library needs it to remain as-is.
Add this line to your proguard configuration, and you should be set:
-keep class android.support.v7.widget.ShareActionProvider { *; }