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

android.os.BadParcelableException: ClassNotFoundException when unmarshalling #57

Open
vsk-pvr opened this issue Oct 5, 2016 · 20 comments
Labels

Comments

@vsk-pvr
Copy link

vsk-pvr commented Oct 5, 2016

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.routeyou.startup/com.routeyou.ui.DownloadRouteActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.akexorcist.roundcornerprogressbar.common.BaseRoundCornerProgressBar$SavedState at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3184) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3294) at android.app.ActivityThread.access$1000(ActivityThread.java:210) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1704) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Caused by android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.akexorcist.roundcornerprogressbar.common.BaseRoundCornerProgressBar$SavedState at android.os.Parcel.readParcelableCreator(Parcel.java:2295) at android.os.Parcel.readParcelable(Parcel.java:2245) at android.view.AbsSavedState.<init>(AbsSavedState.java:57) at android.view.View$BaseSavedState.<init>(View.java:21487) at com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar$SavedState.<init>(TextRoundCornerProgressBar.java:318) at com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar$SavedState.<init>(TextRoundCornerProgressBar.java:306) at com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar$SavedState$1.createFromParcel(TextRoundCornerProgressBar.java:340) at com.akexorcist.roundcornerprogressbar.TextRoundCornerProgressBar$SavedState$1.createFromParcel(TextRoundCornerProgressBar.java:338) at android.os.Parcel.readParcelable(Parcel.java:2252) at android.os.Parcel.readValue(Parcel.java:2152) at android.os.Parcel.readSparseArrayInternal(Parcel.java:2546) at android.os.Parcel.readSparseArray(Parcel.java:1874) at android.os.Parcel.readValue(Parcel.java:2209) at android.os.Parcel.readArrayMapInternal(Parcel.java:2485) at android.os.BaseBundle.unparcel(BaseBundle.java:221) at android.os.Bundle.getSparseParcelableArray(Bundle.java:822) at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2290) at android.app.Activity.onRestoreInstanceState(Activity.java:1170) at android.app.Activity.performRestoreInstanceState(Activity.java:1115) at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1190) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3157) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3294) at android.app.ActivityThread.access$1000(ActivityThread.java:210) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1704) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

@rafiip
Copy link

rafiip commented Jan 14, 2017

same here . i think we should switch to another view

@ManuelGA
Copy link

anyone found a fix for this?

@luizfp
Copy link

luizfp commented Aug 2, 2017

Same problem.

@rcaboni
Copy link

rcaboni commented Aug 22, 2017

Same problem. I think i need to looking for an alternative library.

@leof23
Copy link

leof23 commented Sep 20, 2017

I have the same problem, anyone has a solution??

@luizfp
Copy link

luizfp commented Sep 20, 2017

@leof23 I haven't find any solutions. I'm just slowly switching the use of that view in my project for a new one.

@leof23
Copy link

leof23 commented Sep 20, 2017

@luizfp do you know another good alternative for this component?

@luizfp
Copy link

luizfp commented Sep 20, 2017

@leof23 I don't know any alternatives that are so customizable.

I make one myself using something like this:

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_marginLeft="@dimen/spacing_small"
  android:layout_marginRight="@dimen/spacing_small"
  android:background="@color/dark_gray"
  android:orientation="horizontal"
  android:padding="1.7dp">

  <ImageView
      android:id="@+id/img_progress"
      android:layout_width="30dp"
      android:layout_height="30dp"
      android:background="@color/blue"
      android:padding="@dimen/spacing_tiny"
      android:src="@drawable/ic_hourglass_white" />

  <LinearLayout
      android:id="@+id/progress"
      android:layout_width="match_parent"
      android:layout_height="30dp"
      android:background="@color/dark_gray" />
</LinearLayout>

It's easy to make your own custom view using this simple layout.

With this approach we don't have much control but this fits my needs. One thing is not so easy to reproduce: radius effect. But I can live without this.

@randheer-kiwi
Copy link

@akexorcist Please look at this issue, if possible.

@trenoduro
Copy link

any news on this?

@behelit
Copy link

behelit commented Mar 28, 2018

My users keep reporting the BadParcelableException but it's not due to unmarshalling

Caused by: android.os.BadParcelableException: 
  at android.os.Parcel.readParcelableCreator (Parcel.java:2536)
  at android.os.Parcel.readParcelable (Parcel.java:2462)
  at android.view.AbsSavedState.<init> (AbsSavedState.java:67)
  at android.view.View$BaseSavedState.<init> (View.java:22764)
  at android.view.View$BaseSavedState.<init> (View.java:22753)
  at com.akexorcist.roundcornerprogressbar.IconRoundCornerProgressBar$SavedState.<init> (IconRoundCornerProgressBar.java:314)
  at com.akexorcist.roundcornerprogressbar.IconRoundCornerProgressBar$SavedState.<init> (IconRoundCornerProgressBar.java:297)
  at com.akexorcist.roundcornerprogressbar.IconRoundCornerProgressBar$SavedState$1.createFromParcel (IconRoundCornerProgressBar.java:346)
  at com.akexorcist.roundcornerprogressbar.IconRoundCornerProgressBar$SavedState$1.createFromParcel (IconRoundCornerProgressBar.java:344)
  at android.os.Parcel.readParcelable (Parcel.java:2471)
  at android.os.Parcel.readValue (Parcel.java:2365)
  at android.os.Parcel.readSparseArrayInternal (Parcel.java:2813)
  at android.os.Parcel.readSparseArray (Parcel.java:2068)
  at android.os.Parcel.readValue (Parcel.java:2422)
  at android.os.Parcel.readArrayMapInternal (Parcel.java:2732)
  at android.os.BaseBundle.unparcel (BaseBundle.java:269)
  at android.os.Bundle.getSparseParcelableArray (Bundle.java:934)
  at com.android.internal.policy.PhoneWindow.restoreHierarchyState (PhoneWindow.java:2109)
  at android.app.Activity.onRestoreInstanceState (Activity.java:1060)
  at android.app.Activity.performRestoreInstanceState (Activity.java:1015)
  at android.app.Instrumentation.callActivityOnRestoreInstanceState (Instrumentation.java:1178)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2670)

@rcaboni
Copy link

rcaboni commented May 12, 2018

I create a very simple Progress Bar sample (not a library) in alternative to this beautiful library with this bad bug.
If same one is interested : https://github.com/rcaboni/TestCustomProgress

@CedricCarniel
Copy link

For those desperately needing a fix... here's the dirty one I found :(
I inlined all BaseRoundCornerProgressBar into the derived class

For example, instead of
public class IconRoundCornerProgressBar extends BaseRoundCornerProgressBar
you need
public class IconRoundCornerProgressBar extends LinearLayout
and put all method/properties of BaseRoundCornerProgressBar into IconRoundCornerProgressBar

Find attach a special version... I created a IconTextRoundCornerProgressBar (both Icon and Text features)
You can have a look at it here

IconTextRCPB.zip

@kaleeswaran14
Copy link

kaleeswaran14 commented Sep 20, 2018

For those desperately needing a fix... here's the dirty one I found :(
I inlined all BaseRoundCornerProgressBar into the derived class

For example, instead of
public class IconRoundCornerProgressBar extends BaseRoundCornerProgressBar
you need
public class IconRoundCornerProgressBar extends LinearLayout
and put all method/properties of BaseRoundCornerProgressBar into IconRoundCornerProgressBar

Find attach a special version... I created a IconTextRoundCornerProgressBar (both Icon and Text features)
You can have a look at it here

IconTextRCPB.zip

Great. It is working. Thank you @CedricCarniel . I would like to know, What is the issue ? Why it is working, If we combine the files ?

@alookin-godaddy
Copy link

Same here

@akexorcist
Copy link
Owner

Hey guy

Sorry for huge issue from my library but I can't reproduce this bug.

It will be great, If anyone can provide more information to reproduce it.

@antonlookinpoynt Can you?

@akexorcist akexorcist added the bug label Apr 16, 2020
@akexorcist akexorcist pinned this issue Apr 16, 2020
@akexorcist akexorcist unpinned this issue Apr 16, 2020
@akexorcist akexorcist pinned this issue Apr 16, 2020
@mehul4795
Copy link

Hello, @akexorcist

Steps to reproduce the issue

  1. Run the app and navigate to the screen which shows the progress bar.
  2. Put the app in the background
  3. Kill the app using the "Terminates selected Android Application" option from the Android Studio logcat
  4. Reopen the app using the recents screen

A lot of users are facing this issue. It would be helpful if you can solve and provide an update to the library. Thanks in advance :)

akexorcist added a commit that referenced this issue May 7, 2020
@akexorcist
Copy link
Owner

akexorcist commented May 7, 2020

Good news everyone. I finally fixed it.

It's hard to dig up the problem causing. Because there's no one create custom view with class inheritance like this.

The common solution the save state of custom view doesn't works with these kind of custom view implementation. To solved this, I replace Creator with Parcelable.ClassLoaderCreator and replace BaseSavedState with AbsSavedState. Those class will support the save state for view hierarchy.

@mehul4795 Your steps description is very helpful. Thank you so much.

See you in v2.1.1.

@akexorcist
Copy link
Owner

2.1.1 is out with issue fixed.

Feel free to reopen this issue if it still happen.

@akexorcist akexorcist unpinned this issue May 7, 2020
@akexorcist akexorcist reopened this Dec 27, 2021
@heihitesh
Copy link

Hi @akexorcist is this issue fixed ?

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

No branches or pull requests

16 participants