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.

Issue with the RecyclerView state on Android 5.0.2

See original GitHub issue

I’m using ObservableRecyclerView and it works fine on Android <5. But when I run the same code on Lollipop, I get an exception. The RecyclerView has elements, a click on them starts another activity. When I return from that one, the app crashes with the following exception:

Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.RecyclerView$SavedState
            at android.os.Parcel.readParcelableCreator(Parcel.java:2289)
            at android.os.Parcel.readParcelable(Parcel.java:2239)
            at android.view.AbsSavedState.<init>(AbsSavedState.java:57)
            at android.view.View$BaseSavedState.<init>(View.java:20038)
            at com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView$SavedState.<init>(ObservableRecyclerView.java:265)
            at com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView$SavedState.<init>(ObservableRecyclerView.java:252)
            at com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView$SavedState$1.createFromParcel(ObservableRecyclerView.java:304)
            at com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView$SavedState$1.createFromParcel(ObservableRecyclerView.java:301)
            at android.os.Parcel.readParcelable(Parcel.java:2246)
            at android.os.Parcel.readValue(Parcel.java:2146)
            at android.os.Parcel.readSparseArrayInternal(Parcel.java:2540)
            at android.os.Parcel.readSparseArray(Parcel.java:1868)
            at android.os.Parcel.readValue(Parcel.java:2203)
            at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
            at android.os.BaseBundle.unparcel(BaseBundle.java:221)
            at android.os.Bundle.getSparseParcelableArray(Bundle.java:871)
            at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1979)
            at android.app.Activity.onRestoreInstanceState(Activity.java:1022)
            at android.app.Activity.performRestoreInstanceState(Activity.java:977)
            at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1161)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2271)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            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:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

It looks like on Lollipop, the android.support.v7.widget.RecyclerView is not used by the app since it has the native one available. But the ObservableRecyclerView references that one, leading to the crash.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
anshul1235commented, Dec 24, 2014

It happened for me in kitkat too!

0reactions
icodeyoucommented, Dec 5, 2016

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

RecyclerView - Scroll To Position Not Working Every Time
The main reason for this issue is that the recycler view may not be ready by the time you ask it to scroll....
Read more >
RecyclerView.State | Android Developers
Contains useful information about the current RecyclerView state like target scroll position or view focus. State object can also keep arbitrary ...
Read more >
The item inside RecyclerView can't be clicked right after scrolling
I think the problem is the scrollState of the RecyclerView. When it's stopped scrolling, it's not changed to SCROLL_STATE_IDLE immediately.
Read more >
What's New in Release 5.1.1 - SAP Help Portal
Fixed issue where Voice Search was not functional on devices running Android 11 or later. Fixed incorrect rendering of Buttons that are in...
Read more >
RecyclerView in Android: The basics - Antonio Leiva
You will have to override two main methods: one to inflate the view and its view holder, and another one to bind data...
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