material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[BottomNavigationView] Component not rendered in preview

Open archer-65 opened this issue 5 years ago • 12 comments

Description: BottomNavigationView not rendering properly in XML Design

Expected behavior: BottomNavigationView renders correctly

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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

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

</androidx.constraintlayout.widget.ConstraintLayout>

Android API version: API 30

Material Library version: 1.5.0-alpha05 (tried also alpha04)

Device: Pixel 3 XL API 29 & Pixel 5 API 30

bug

archer-65 avatar Nov 02 '21 20:11 archer-65

For me, it's not even working on test devices. I'm using 1.5.0-alpha05 material library. P.S. I mean the bottom nav bar is in old style, not "material you".

myralchista avatar Nov 03 '21 13:11 myralchista

I think this has been fixed. Feel free to reopen it if it's still reproducible.

drchen avatar Nov 29 '21 19:11 drchen

I think this has been fixed. Feel free to reopen it if it's still reproducible.

I've tried, it doesn't work, same problem...

archer-65 avatar Nov 30 '21 12:11 archer-65

+1 here, 1.5.0 stable

themronion avatar Jan 22 '22 15:01 themronion

Still having the same problem in 1.5.0 - I'm getting: The following classes could not be instantiated: - com.google.android.material.bottomnavigation.BottomNavigationView

Exception Details: java.lang.IllegalArgumentException: Motion easing theme attribute must be a string at com.google.android.material.motion.MotionUtils.resolveThemeInterpolator

Only going back to 1.4.0 seems to work.

Freesebee avatar Jan 24 '22 11:01 Freesebee

Hello, can you check if this is still an issue with the latest Canary build of Android Studio? If so I think a bug should be filed for Android Studio.

dsn5ft avatar Jan 24 '22 14:01 dsn5ft

Still failed, Build #AI-213.7172.25.2113.9123335, built on September 30, 2022

Lak4CYUT avatar Dec 04 '22 20:12 Lak4CYUT

dependencies {
....
   implementation 'com.google.android.material:material:1.5.0'
....
}

Got the following when I tried to add BottomNavigationView inside a Constraint Layout

The following classes could not be instantiated:
- com.google.android.material.bottomnavigation.BottomNavigationView (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  

Exception Details java.lang.IllegalArgumentException: Motion easing theme attribute must be a string   java.lang.IllegalArgumentException: Motion easing theme attribute must be a string
	at com.google.android.material.motion.MotionUtils.resolveThemeInterpolator(MotionUtils.java:59)
	at com.google.android.material.navigation.NavigationBarMenuView.<init>(NavigationBarMenuView.java:121)
	at com.google.android.material.bottomnavigation.BottomNavigationMenuView.<init>(BottomNavigationMenuView.java:48)
	at com.google.android.material.bottomnavigation.BottomNavigationView.createNavigationBarMenuView(BottomNavigationView.java:215)
	at com.google.android.material.navigation.NavigationBarView.<init>(NavigationBarView.java:162)
	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.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:351)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:200)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
	at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
	at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

shehabadel avatar Dec 07 '22 10:12 shehabadel

dependencies {
....
   implementation 'com.google.android.material:material:1.5.0'
....
}

Got the following when I tried to add BottomNavigationView inside a Constraint Layout

The following classes could not be instantiated:
- com.google.android.material.bottomnavigation.BottomNavigationView (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  

Exception Details java.lang.IllegalArgumentException: Motion easing theme attribute must be a string   java.lang.IllegalArgumentException: Motion easing theme attribute must be a string
	at com.google.android.material.motion.MotionUtils.resolveThemeInterpolator(MotionUtils.java:59)
	at com.google.android.material.navigation.NavigationBarMenuView.<init>(NavigationBarMenuView.java:121)
	at com.google.android.material.bottomnavigation.BottomNavigationMenuView.<init>(BottomNavigationMenuView.java:48)
	at com.google.android.material.bottomnavigation.BottomNavigationView.createNavigationBarMenuView(BottomNavigationView.java:215)
	at com.google.android.material.navigation.NavigationBarView.<init>(NavigationBarView.java:162)
	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.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:351)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:200)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
	at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
	at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

I have the exact same issue. Is this issue fixed ?

JyotimoyKashyap avatar Dec 14 '22 07:12 JyotimoyKashyap

dependencies {
....
   implementation 'com.google.android.material:material:1.5.0'
....
}

Got the following when I tried to add BottomNavigationView inside a Constraint Layout

The following classes could not be instantiated:
- com.google.android.material.bottomnavigation.BottomNavigationView (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  

Exception Details java.lang.IllegalArgumentException: Motion easing theme attribute must be a string   java.lang.IllegalArgumentException: Motion easing theme attribute must be a string
	at com.google.android.material.motion.MotionUtils.resolveThemeInterpolator(MotionUtils.java:59)
	at com.google.android.material.navigation.NavigationBarMenuView.<init>(NavigationBarMenuView.java:121)
	at com.google.android.material.bottomnavigation.BottomNavigationMenuView.<init>(BottomNavigationMenuView.java:48)
	at com.google.android.material.bottomnavigation.BottomNavigationView.createNavigationBarMenuView(BottomNavigationView.java:215)
	at com.google.android.material.navigation.NavigationBarView.<init>(NavigationBarView.java:162)
	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.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:351)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:200)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
	at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
	at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

I have the exact same issue. Is this issue fixed ?

It was fixed after downgrading the material dependency to 1.4.0.

dependencies {
....
   implementation 'com.google.android.material:material:1.4.0'
....
}

shehabadel avatar Dec 14 '22 07:12 shehabadel

This issue is fixed with material version 1.8.0

JyotimoyKashyap avatar Dec 14 '22 08:12 JyotimoyKashyap

dependencies {
....
   implementation 'com.google.android.material:material:1.5.0'
....
}

Got the following when I tried to add BottomNavigationView inside a Constraint Layout

The following classes could not be instantiated:
- com.google.android.material.bottomnavigation.BottomNavigationView (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  

Exception Details java.lang.IllegalArgumentException: Motion easing theme attribute must be a string   java.lang.IllegalArgumentException: Motion easing theme attribute must be a string
	at com.google.android.material.motion.MotionUtils.resolveThemeInterpolator(MotionUtils.java:59)
	at com.google.android.material.navigation.NavigationBarMenuView.<init>(NavigationBarMenuView.java:121)
	at com.google.android.material.bottomnavigation.BottomNavigationMenuView.<init>(BottomNavigationMenuView.java:48)
	at com.google.android.material.bottomnavigation.BottomNavigationView.createNavigationBarMenuView(BottomNavigationView.java:215)
	at com.google.android.material.navigation.NavigationBarView.<init>(NavigationBarView.java:162)
	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.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:351)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:200)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:294)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1127)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1130)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1101)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:359)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:436)
	at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:121)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:717)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$9(RenderTask.java:873)
	at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$3.run(RenderExecutor.kt:192)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

I have the exact same issue. Is this issue fixed ?

It was fixed after downgrading the material dependency to 1.4.0.

dependencies {
....
   implementation 'com.google.android.material:material:1.4.0'
....
}

yes it works 1.4.0

abderrahim-bgh avatar Dec 14 '22 12:12 abderrahim-bgh