Random nullref from BottomNavigationView
Xamarin.Android Version (eg: 6.0):
Xamarin.Android Version: 8.3.3.2 (Visual Studio Enterprise) Android SDK: /Users/Ulrich/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 7.1 (API level 25) 8.0 (API level 26) 8.1 (API level 27)
SDK Tools Version: 26.1.1 SDK Platform Tools Version: 27.0.1 SDK Build Tools Version: 27.0.3
Java SDK: /usr java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Operating System & Version (eg: Mac OSX 10.11):
Mac OSX 10.13.4
Support Libraries Version (eg: 23.3.0):
27.0.2.1
Describe your Issue:
When using a BottomNavigationView I often get a nullref exception, when inflating the axml inside an activity. (see stack trace)
<android.support.design.widget.BottomNavigationView
android:id="@+id/MainTabBottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBackground="@color/SemiBlack"
app:itemIconTint="@drawable/bottom_navigation_tab_selector"
app:menu="@menu/main_navigation_menu" />
I can workaround the issue by deleting bin/obj folders. If I afterwards, either change device or change the working branch, I'll see the nullref again, and have to do the workaround one more time.
I have tried to set the linker behaviour to don't link, and has added the BottomNavigationView multidex.keep . It doesn't seem to help.
Include any relevant Exception Stack traces, build logs, adb logs:
Binary XML file line #1: Binary XML file line #1: Error inflating class android.support.design.widget.BottomNavigationView
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in
Binary XML file line #1: Error inflating class android.support.design.widget.BottomNavigationView
--- End of managed Android.Views.InflateException stack trace ---
android.view.InflateException: Binary XML file line #1: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:652)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at md5f79b6dfb4cc412c50e23f2d588832d36.BindableViewBase_1.n_onCreate(Native Method)
at md5f79b6dfb4cc412c50e23f2d588832d36.BindableViewBase_1.onCreate(BindableViewBase_1.java:68)
at android.app.Activity.performCreate(Activity.java:6942)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTextColor(android.content.res.ColorStateList)' on a null object reference
at android.support.design.internal.BottomNavigationItemView.setTextColor(BottomNavigationItemView.java:249)
at android.support.design.internal.BottomNavigationMenuView.buildMenuView(BottomNavigationMenuView.java:278)
at android.support.design.internal.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:62)
at android.support.design.widget.BottomNavigationView.inflateMenu(BottomNavigationView.java:236)
at android.support.design.widget.BottomNavigationView.
Exception of type 'Java.Lang.Reflect.InvocationTargetException' was thrown.
--- End of managed Java.Lang.Reflect.InvocationTargetException stack trace ---
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:652)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:873)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:525)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at md5f79b6dfb4cc412c50e23f2d588832d36.BindableViewBase_1.n_onCreate(Native Method)
at md5f79b6dfb4cc412c50e23f2d588832d36.BindableViewBase_1.onCreate(BindableViewBase_1.java:68)
at android.app.Activity.performCreate(Activity.java:6942)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2880)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTextColor(android.content.res.ColorStateList)' on a null object reference
at android.support.design.internal.BottomNavigationItemView.setTextColor(BottomNavigationItemView.java:249)
at android.support.design.internal.BottomNavigationMenuView.buildMenuView(BottomNavigationMenuView.java:278)
at android.support.design.internal.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:62)
at android.support.design.widget.BottomNavigationView.inflateMenu(BottomNavigationView.java:236)
at android.support.design.widget.BottomNavigationView.
Attempt to invoke virtual method 'void android.widget.TextView.setTextColor(android.content.res.ColorStateList)' on a null object reference
--- End of managed Java.Lang.NullPointerException stack trace ---
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTextColor(android.content.res.ColorStateList)' on a null object reference
at android.support.design.internal.BottomNavigationItemView.setTextColor(BottomNavigationItemView.java:249)
at android.support.design.internal.BottomNavigationMenuView.buildMenuView(BottomNavigationMenuView.java:278)
at android.support.design.internal.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:62)
at android.support.design.widget.BottomNavigationView.inflateMenu(BottomNavigationView.java:236)
at android.support.design.widget.BottomNavigationView.
Still an issue for me :/