如果我从“bin”文件中获取apk,该应用程序运行良好。但是如果我导出apk,那么无论我是否使用Proguard,应用程序都会出错。为什么???
另外,我发现了一件非常有趣的事情。我试图多次导出apk(超过100次),有时我可以导出一个很好的apk。好的apk大小(1.92 MB)将小于错误apk(1.20 MB)。
错误
08-31 02:25:11.759: E/AndroidRuntime(3947): FATAL EXCEPTION: main
08-31 02:25:11.759: E/AndroidRuntime(3947): java.lang.NullPointerException
08-31 02:25:11.759: E/AndroidRuntime(3947): at com.queue.MainActivity.onCreateOptionsMenu(Unknown Source)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.app.Activity.onCreatePanelMenu(Activity.java:2577)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.support.v4.app.j.onCreatePanelMenu(Unknown Source)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.support.v7.a.g.a(Unknown Source)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.support.v7.a.l.a(Unknown Source)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.support.v7.a.g.onCreatePanelMenu(Unknown Source)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.support.v7.a.m.onCreatePanelMenu(Unknown Source)
08-31 02:25:11.759: E/AndroidRuntime(3947): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:414)
08-31 02:25:11.759: E/AndroidRuntime(3947): at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:777)
08-31 02:25:11.759: E/AndroidRuntime(3947): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:199)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.os.Handler.handleCallback(Handler.java:730)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.os.Handler.dispatchMessage(Handler.java:92)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.os.Looper.loop(Looper.java:150)
08-31 02:25:11.759: E/AndroidRuntime(3947): at android.app.ActivityThread.main(ActivityThread.java:5390)
08-31 02:25:11.759: E/AndroidRuntime(3947): at java.lang.reflect.Method.invokeNative(Native Method)
08-31 02:25:11.759: E/AndroidRuntime(3947): at java.lang.reflect.Method.invoke(Method.java:525)
08-31 02:25:11.759: E/AndroidRuntime(3947): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-31 02:25:11.759: E/AndroidRuntime(3947): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-31 02:25:11.759: E/AndroidRuntime(3947): at dalvik.system.NativeStart.main(Native Method)
08-31 02:25:11.759: W/ActivityManager(448): Force finishing activity com.queue/.MainActivity
08-31 02:25:11.769: E/IMGSRV(165): :0: PVRDRMOpen: TP3, ret = 71
代码
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
SearchManager SManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
SearchView searchViewAction = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
searchViewAction.setSearchableInfo(SManager.getSearchableInfo(getComponentName()));
return super.onCreateOptionsMenu(menu);
}