0
當我嘗試打開任何Option Menu
但僅在發佈模式時發生此問題。在調試模式下,一切都按預期工作。'void android.widget.TextView.setText(java.lang.CharSequence)'在空對象引用上但僅在發佈模式下
錯誤日誌亞行:
01-31 01:55:58.587 5986 5986 D AndroidRuntime: Shutting down VM
01-31 01:55:58.613 5986 5986 E AndroidRuntime: FATAL EXCEPTION: main
01-31 01:55:58.613 5986 5986 E AndroidRuntime: Process: com.pokinia.app, PID: 5986
01-31 01:55:58.613 5986 5986 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.support.v7.view.menu.ListMenuItemView.setTitle(ListMenuItemView.java:117)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.support.v7.view.menu.ListMenuItemView.initialize(ListMenuItemView.java:104)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.support.v7.view.menu.MenuPopupHelper$MenuAdapter.getView(MenuPopupHelper.java:381)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.support.v7.view.menu.MenuPopupHelper.measureContentWidth(MenuPopupHelper.java:223)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.support.v7.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:157)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.support.v7.widget.ActionMenuPresenter$OpenOverflowRunnable.run(ActionMenuPresenter.java:785)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-31 01:55:58.613 5986 5986 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
正如在許多其他線程表示,這意味着一些值爲空,但因爲它的工作在調試我不知道如何弄清楚發生了什麼事情。
Null object reference on setText in Android app
我的工具欄:
mToolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(mToolbar);
我怎樣才能找出哪些屬性導致此問題是否只出現在發佈模式?
可以爲您發佈'ListMenuItemView.java'? –
發佈版本中的「Linker」設置是什麼?您是否啓用了「Proguard」? – SushiHangover
@vrundpurohit'ListMenuItemView.java'不是自定義類,它支持lib:'android.support.v7.view.menu.ListMenuItemView' –