'void android.widget.TextView.setText(java.lang.CharSequence)'在空对象引用上但仅在发布模式下

时间:2017-01-31 08:04:43

标签: android xamarin xamarin.android

当我尝试打开任何Option Menu但仅在发布模式时,会出现此问题。在调试模式下,一切都按预期工作。

来自亚行的错误记录:

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但是因为它在Debug中工作,我不知道如何弄清楚发生了什么。

Null object reference on setText in Android app

我的工具栏:

mToolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(mToolbar);

如果问题仅出现在发布模式中,我如何确定导致此问题的属性?

1 个答案:

答案 0 :(得分:0)

这解决了它:

  • 清洁解决方案

  • 重建解决方案