我通过启用 minifyEnabled 属性生成了发布版本,当我尝试运行发布版本时,它会强制关闭并显示以下日志。请帮我调试一下
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)
这是我的方法 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);
}