Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the RecyclerView state on Android 5.0.2 #27

Closed
scan opened this issue Dec 23, 2014 · 12 comments
Closed

Issue with the RecyclerView state on Android 5.0.2 #27

scan opened this issue Dec 23, 2014 · 12 comments

Comments

@scan
Copy link

scan commented Dec 23, 2014

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.

@anshul1235
Copy link

It happened for me in kitkat too!

@ksoichiro
Copy link
Owner

@scan, @anshul1235, thank you for your feedback.
How did you build the app?
Does it also happen on the one that is published on the Google Play Store?
As @scan says, ObservableRecyclerView extends android.support.v7.widget.RecyclerView and it depends on that class.
If you build the sample app with Eclipse, you need to add android-support-v7-recyclerview.jar to your build paths.
(Please see docs/eclipse.md for details.)

@scan
Copy link
Author

scan commented Dec 24, 2014

I used the method described in the Readme, using Idea and Gradle. And it does not happen on the version published in the Play Store, because the bug only happens when you return to an activity, triggering onRestoreSaveState. There is no such case involving RecyclerView in the example.

@ksoichiro
Copy link
Owner

@scan Thank you. I'll check later.

ksoichiro added a commit that referenced this issue Dec 25, 2014
@ksoichiro
Copy link
Owner

There was a problem in ObservableRecyclerView and I made a fix for this.
Could you please check the latest version?

If you use Eclipse, copy the latest ObservableRecyclerView code into your project.
If you use gradle, use 1.3.2-SNAPSHOT like this:

repositories {
    mavenCentral()
    maven {
        url uri('https://oss.sonatype.org/content/repositories/snapshots/')
    }
}

dependencies {
    compile "com.github.ksoichiro:android-observablescrollview:1.3.2-SNAPSHOT"
}

@scan
Copy link
Author

scan commented Dec 27, 2014

I kind of stopped using ObservableRecyclerView after the problems, but I went back in my commit list and checked with the new version of the lib, seems to run now.

@scan scan closed this as completed Dec 27, 2014
@ksoichiro
Copy link
Owner

@scan Thank you for reporting and checking this!

@ppamorim
Copy link

ppamorim commented Sep 1, 2015

+1 Still happens this problem.

@oshurmamadov
Copy link

++ Still happens

@lehno
Copy link

lehno commented Jan 26, 2016

+1 Still happens this problem.

@onexuan
Copy link

onexuan commented Jun 20, 2016

this issue is support lib bug, https://code.google.com/p/android/issues/detail?id=196430

@icodeyou
Copy link

icodeyou commented Dec 5, 2016

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants