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] TabLayout crashes randomly.

See original GitHub issue

Description: For simple implementation, I have code that removes all tabs and adds them in one cycle. The line listView.removeAllTabs() crashes intermittently.

Expected behavior: Tabs are updated with the newest list reliable, all the time.

Source code: Code:

listView.removeAllTabs()
list.forEach {
    val tab = listView.newTab()
    tab.text = it
    listView.addTab(tab)
}

XML:

<com.google.android.material.tabs.TabLayout
        android:id="@+id/layout_currency_tab"
        android:layout_width="match_parent"
        android:layout_height="32dp"
        android:overScrollMode="always"
        app:layout_constraintTop_toBottomOf="@id/action_bar"
        app:tabIndicatorColor="@color/text_regular"
        app:tabIndicatorFullWidth="false"
        app:tabMode="scrollable"
        app:tabTextAppearance="@style/CurrencyCodeTab"
        app:tabTextColor="@color/text_regular" />

Crash log:

2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542] JNI DETECTED ERROR IN APPLICATION: JNI NewLocalRef called with pending exception java.lang.UnsupportedOperationException: Failed to resolve attribute at index 4: TypedValue{t=0x2/d=0x1010099 a=1}
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at int android.content.res.TypedArray.getColor(int, int) (TypedArray.java:477)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void android.widget.TextView.readTextAppearance(android.content.Context, android.content.res.TypedArray, android.widget.TextView$TextAppearanceAttributes, boolean) (TextView.java:3539)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void android.widget.TextView.setTextAppearance(android.content.Context, int) (TextView.java:3408)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void androidx.appcompat.widget.AppCompatTextView.setTextAppearance(android.content.Context, int) (AppCompatTextView.java:185)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void android.widget.TextView.setTextAppearance(int) (TextView.java:3395)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void androidx.core.widget.TextViewCompat.setTextAppearance(android.widget.TextView, int) (TextViewCompat.java:284)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void com.google.android.material.tabs.TabLayout$TabView.update() (TabLayout.java:2247)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void com.google.android.material.tabs.TabLayout$TabView.setTab(com.google.android.material.tabs.TabLayout$Tab) (TabLayout.java:2173)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void com.google.android.material.tabs.TabLayout$TabView.reset() (TabLayout.java:2178)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void com.google.android.material.tabs.TabLayout.removeTabViewAt(int) (TabLayout.java:1503)
2019-09-22 14:40:19.255 7685-7685/myapp.dev A/t7.myapp.de: java_vm_ext.cc:542]   at void com.google.android.material.tabs.TabLayout.removeAllTabs() (TabLayout.java:789)

Android API version: API 28

Material Library version: 1.0.0

Device: Nexus 5X emulator

To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
leticiarossicommented, Nov 12, 2019

Will close it since we’re not able to reproduce it and you haven’t seen this anymore. Feel free to reopen and attach a sample app if the issue comes up again

0reactions
ForceTowercommented, Feb 16, 2021

Yep, after adding the <item name="android:textColorHighlight">@color/controlHighlight</item> in the theme the error is gone and the users no longer need to clear app data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TabLayout in 23.2.0 can crash when it tries to reuse Tabs from ...
When it tries to reuse Tabs from this Pool it can crash. Caused by: java.lang.IllegalArgumentException: Tab belongs to a different TabLayout.
Read more >
java - I got my app Crash when i swipe in viewpager and tab ...
I had added 3 tab and when i swipe the view pager it will load for a sec and crash and same in...
Read more >
[Solved]-How to fix google sign In option function getting duplicate ...
Coding example for the question How to fix google sign In option function getting duplicate and crash when switching between tablayout-android-Java.
Read more >
Xamarin Forms Tabbed pages crash when switching ... - MSDN
When I switch between tabs app randomly crashes with the same stack ... selectTab(TabLayout.java:1025) at android.support.design.widget.
Read more >
Meshtastic Android 1.2.53 alpha - Releases
What's Changed 1.2.52 by @andrekir in #331 fix tabLayout smoothScroll crash by @andrekir in #335 add provideLocati…
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