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.

[TabLayout] Instantiation error in AndroidStudio

See original GitHub issue

Description: When I use the library com.google.android.material:material:1.8.0-alhpa01 and add a TabLayout to any layout in AndroidStudio, I get the following notice:

java.lang.IllegalArgumentException: Motion easing theme attribute must be an @interpolator resource for ?attr/motionEasing*Interpolator attributes or a string for ?attr/motionEasing* attributes.
	at com.google.android.material.motion.MotionUtils.resolveThemeInterpolator(MotionUtils.java:74)
	at com.google.android.material.tabs.TabLayout.<init>(TabLayout.java:614)
	at com.google.android.material.tabs.TabLayout.<init>(TabLayout.java:509)
	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.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)

Expected behavior: AndroidStudio should show a preview of the TabLayout

Source code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <androidx.viewpager2.widget.ViewPager2
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/tabLayout" />

</RelativeLayout>
implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "com.google.android.material:material:1.8.0-alpha01"

Android API version: 33

Material Library version: 1.8.0-alpha01

Device: AndroidStudio

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
patzlycommented, Dec 3, 2022

@Gizmodo @shalva97 @daniel-reinhold I just tested the latest Android Studio canary build (2022.2.1) with 1.8.0-alpha03 and the layout preview works for me again! The latest release candidate of Electric Eel still doesn’t work, so I think I will work with Flamingo for the next months.

2reactions
Gizmodocommented, Nov 26, 2022

I created an issue here https://issuetracker.google.com/issues/258646238 Upvote it, please!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my tab layout for android not working? - Stack Overflow
I am trying to make a tab sliding activity for my app but I am not able to find what is going wrong....
Read more >
TabLayout | Android Developers
If a tab is instantiated with TabLayout.Tab.setText(CharSequence) , and this mode is set, the text will be saved and utilized for the content ......
Read more >
Android TabLayout - Javatpoint
TabLayout is used to implement horizontal tabs. TabLayout is released by Android after the deprecation of ActionBar.TabListener (API level 21). TabLayout is ...
Read more >
Creating an Android Tabbed Interface using the TabLayout ...
Create a new project in Android Studio, entering TabLayoutDemo into the Application name field and ebookfrenzy.com as the Company Domain setting before clicking ......
Read more >
TabLayout is very inefficient when having many tabs [37053935]
TabLayout will instantiate a view for every tab. If you declare a ViewPager with virtually infinite pages (i.e. a big number of pages)...
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