question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BottomNavigationView] Crash when inflating Menu

See original GitHub issue

Description: When using app:menu attribute, app crashes. When its empty, app runs normally.

Expected behavior: Expects to correct inflate menu.

Source code: ` <androidx.constraintlayout.widget.ConstraintLayout xmlns:android=“http://schemas.android.com/apk/res/android” xmlns:app=“http://schemas.android.com/apk/res-auto” xmlns:tools=“http://schemas.android.com/tools” android:id=“@+id/doors_activity_id” android:layout_width=“match_parent” android:layout_height=“match_parent”>

<com.google.android.material.appbar.AppBarLayout
    android:id="@+id/appBarLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay"
    app:elevation="0dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/mainBackground"
        />
</com.google.android.material.appbar.AppBarLayout>

<FrameLayout
    android:id="@+id/frameContainer"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/appBarLayout">

</FrameLayout>

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottomNavigationView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:menu="@menu/bottom_navigation_menu"/>

</androidx.constraintlayout.widget.ConstraintLayout>`

Android API version: Api 28

Material Library version: Material Android Library version you are using here (e.g., 1.1.0-Beta01)

Device: Occurs on Simulator and on Physical Device Stacktrack: E/AndroidRuntime: FATAL EXCEPTION: main Process: br.com.loopkey.indigo, PID: 6621 java.lang.NoSuchFieldError: No static field smallLabel of type I in class Lcom/google/android/material/R$id; or its superclasses (declaration of 'com.google.android.material.R$id' appears in /data/app/br.com.loopkey.indigo-cXAvVjFvNTsdqhGXDjsjMw==/base.apk!classes2.dex) at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:97) at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:84) at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:80) at com.google.android.material.bottomnavigation.BottomNavigationMenuView.getNewItem(BottomNavigationMenuView.java:588) at com.google.android.material.bottomnavigation.BottomNavigationMenuView.buildMenuView(BottomNavigationMenuView.java:520) at com.google.android.material.bottomnavigation.BottomNavigationPresenter.updateMenuView(BottomNavigationPresenter.java:67) at com.google.android.material.bottomnavigation.BottomNavigationView.inflateMenu(BottomNavigationView.java:343) at br.com.loopkey.indigo.presentation.view.activity.DoorActivity._setupBottomNavigation(DoorActivity.kt:78) at br.com.loopkey.indigo.presentation.view.activity.DoorActivity.onCreate(DoorActivity.kt:43) at android.app.Activity.performCreate(Activity.java:7224) at android.app.Activity.performCreate(Activity.java:7213) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6806) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rlmaxcommented, Oct 19, 2020

same here

0reactions
hammadbawaracommented, Sep 3, 2022

I am also facing this issue. My app is working perfectly on android 9 and android 7. But it is not working on android 5. It is giving this on logcat

2022-09-03 14:19:10.408 26942-26942/com.hz_apps.gallerylocker E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.hz_apps.gallerylocker, PID: 26942
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hz_apps.gallerylocker/com.hz_apps.gallerylocker.MainActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2505)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577)
        at android.app.ActivityThread.access$1000(ActivityThread.java:164)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:160)
        at android.app.ActivityThread.main(ActivityThread.java:5541)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
     Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
        at android.view.LayoutInflater.createView(LayoutInflater.java:633)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
        at com.hz_apps.gallerylocker.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:55)
        at com.hz_apps.gallerylocker.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:49)
        at com.hz_apps.gallerylocker.MainActivity.onCreate(MainActivity.java:29)
        at android.app.Activity.performCreate(Activity.java:6093)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577) 
        at android.app.ActivityThread.access$1000(ActivityThread.java:164) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:160) 
        at android.app.ActivityThread.main(ActivityThread.java:5541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
        at android.view.LayoutInflater.createView(LayoutInflater.java:607)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
        at com.hz_apps.gallerylocker.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:55) 
        at com.hz_apps.gallerylocker.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:49) 
        at com.hz_apps.gallerylocker.MainActivity.onCreate(MainActivity.java:29) 
        at android.app.Activity.performCreate(Activity.java:6093) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577) 
        at android.app.ActivityThread.access$1000(ActivityThread.java:164) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:160) 
        at android.app.ActivityThread.main(ActivityThread.java:5541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) 
     Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f080094
        at android.content.res.Resources.getValue(Resources.java:1333)
        at androidx.appcompat.widget.ResourceManagerInternal.loadDrawableFromDelegates(ResourceManagerInternal.java:257)
        at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:144)
        at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:137)
        at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:66)
        at androidx.appcompat.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:509)
        at com.google.android.material.navigation.NavigationBarItemView.initialize(NavigationBarItemView.java:196)
        at com.google.android.material.navigation.NavigationBarMenuView.buildMenuView(NavigationBarMenuView.java:707)
        at com.google.android.material.navigation.NavigationBarPresenter.updateMenuView(NavigationBarPresenter.java:72)
        at com.google.android.material.navigation.NavigationBarView.inflateMenu(NavigationBarView.java:386)
        at com.google.android.material.navigation.NavigationBarView.<init>(NavigationBarView.java:280)
        at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:108)
        at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:103)
        at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:98)
        at java.lang.reflect.Constructor.newInstance(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
        at com.hz_apps.gallerylocker.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:55) 
        at com.hz_apps.gallerylocker.databinding.ActivityMainBinding.inflate(ActivityMainBinding.java:49) 
        at com.hz_apps.gallerylocker.MainActivity.onCreate(MainActivity.java:29) 
        at android.app.Activity.performCreate(Activity.java:6093) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2458) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2577) 
        at android.app.ActivityThread.access$1000(ActivityThread.java:164) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1462) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:160) 
        at android.app.ActivityThread.main(ActivityThread.java:5541) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

BottomNavigationView XML

<com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_nav_main_activity"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="0dp"
        android:layout_marginEnd="0dp"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/bottom_nav_menu" />
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error inflating class com.google.android ... - Stack Overflow
BottomNavigationView on my Kotlin application. While running the application, My application got crash, I got the below error,
Read more >
Hands-on with Material Components for Android: Bottom ...
Note: Attempting to inflate a menu with more than 5 items will crash with an IllegalStateException . To dynamically determine the max number...
Read more >
After Adding Android Zoom SDK, App is crashing on ...
Create BottomNavigationView with menu to MainActivity and Add the ZoomSDK to the app and run the app. By running you will get following...
Read more >
BottomNavigationView replace the existing menu [37130153]
Hi, I's impossible to replace the menu of a BottomNavigationView. If you do a clear on the menu before, you got the following...
Read more >
Migrate to the Navigation component - Android Developers
Setting this property inflates the nav graph and sets the graph ... both BottomNavigationView-based navigation and Menu-based navigation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found