Android E/Parcel﹕ Class Not Found When Unmarshalling (Only on Samsung Tab3)

Android E/Parcel﹕ Class not found when unmarshalling (only on Samsung Tab3)

For some strange reason it looks like the class loader isn't set up properly.

Try one of the following in TestActivity.onCreate():


TestParcel cfgOptions = getIntent().getParcelableExtra("cfgOptions");

Intent intent = getIntent();
intent.setExtrasClassLoader(TestParcel.class.getClassLoader());
TestParcel cfgOptions = intent.getParcelableExtra("cfgOptions");

Bundle extras = getIntent().getExtras();
extras.setClassLoader(TestParcel.class.getClassLoader());
TestParcel cfgOptions = extras.getParcelable("cfgOptions");

Alternatively, wrap the parcelable into a bundle:

Bundle b = new Bundle();
b.putParcelable("options", cfgOptions);
Intent intent = new Intent(MDex.this, TestActivity.class);
intent.putExtra("bundle", b);

to get:

Bundle b = getIntent().getBundleExtra("bundle");
TestParcel cfgOptions = b.getParcelable("options");

E/Parcel: Class not found when unmarshalling class with @Parcelize

The problem could be the @RawValue annotation.

From its javadoc:

Write the corresponding property value with [android.os.Parcel.writeValue].
Serialization may fail at runtime, depending on actual property value type.

It may be having some trouble serializing the generic type T. That's all I can guess without more details on which class couldn't be found.

I would suggest that you avoid using that annotation and use the compiler generics options like so:

@Parcelize
data class GenericList<T : Parcelable>(
@SerializedName("…") val data: List<T>
) : Parcelable

I may also suggest, if it could be possible, making AbsPlot an interface and mark as Parcelable each of the implementations of the interface.

Another thing that makes me doubt is to check whether the class Ratings is Parcelable.

How to fix Parcel: Class not found when unmarshalling: androidx.fragment.app.FragmentManagerState after updating material lib?

finally i found a solution. as soon as i updated material library i should have used theme adjusting in a newer way:

AppCompatDelegate.setDefaultNightMode(nightMode)

instead of

val newConfig = Configuration(activity.resources.configuration)
newConfig.uiMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK.inv()
newConfig.uiMode = newConfig.uiMode or uiNightMode
activity.resources.updateConfiguration(newConfig, null)
activity.setTheme(theme)

i just have replaced these piece of code and inherit app themes from Theme.AppCompat.DayNight and now it works like a charm!

Android java.lang.RuntimeException: Parcelable encounteredClassNotFoundException reading a Serializable object

Simply use the enum ordinal as extra using Enum.ordinal(); additionally, this should make your RootNavigationOption.getValuePosition() obsolete.

Example:

final Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(Constants.VIEW_MODE, RootNavigationOption.SETTINGS.ordinal());

Later in your MainActivity (or similar):

final int defaultViewModeOrdinal = RootNavigationOption.HOME.ordinal();
final int viewModeOrdinal = getIntent().getIntExtra(Constants.VIEW_MODE, defaultViewModeOrdinal);
final RootNavigationOption viewMode = RootNavigationOption.values()[viewModeOrdinal];


Related Topics



Leave a reply



Submit