Status Update
Comments
al...@gmail.com <al...@gmail.com> #2
I found the root cause! The fragment savedstate class uses a null class loader. Come on, that's Android 101! The correct creator should be:
public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in, getClass().getClassLoader()); // <------
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
For wondering how to fix this, reflection will do the trick:
// TODOhttps://issuetracker.google.com/issues/74354091
val fragmentStateField: Field = Fragment.SavedState::class.java
.getDeclaredField("mState").apply {
isAccessible = true
}
// ...
(fragmentStateField.get(savedState) as Bundle).classLoader = javaClass.classLoader
public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in, getClass().getClassLoader()); // <------
}
@Override
public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
For wondering how to fix this, reflection will do the trick:
// TODO
val fragmentStateField: Field = Fragment.SavedState::class.java
.getDeclaredField("mState").apply {
isAccessible = true
}
// ...
(fragmentStateField.get(savedState) as Bundle).classLoader = javaClass.classLoader
ku...@google.com <ku...@google.com>
ku...@google.com <ku...@google.com> #3
Thank you for reporting this issue. For us to further investigate this issue, please provide the following additional information:
Android bug report
After reproducing the issue, press the volume up, volume down, and power button simultaneously. This will capture a bug report on your device in the “bug reports” directory. Attach the bug report file to this issue.
Alternate method:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Android bug report
After reproducing the issue, press the volume up, volume down, and power button simultaneously. This will capture a bug report on your device in the “bug reports” directory. Attach the bug report file to this issue.
Alternate method:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
dn...@google.com <dn...@google.com> #4
Please provide the information requested in comment #3 to investigate this issue further.
na...@gmail.com <na...@gmail.com> #5
ku...@google.com <ku...@google.com> #6
nabrozidhs@, can you please provide the android bug report to confirm that is duplicate or not.
na...@gmail.com <na...@gmail.com> #7
You can see it on the issue link I posted on the previous email. Checking the stack trace both go through a ViewPager/FragmentStatePagerAdapter before failing on the same issue.
Description
Version used: 27.1.0
Devices/Android versions reproduced on: PIxel 2 Xl
Project to try it on:
Setup instructions:
If you set the background process limit to 0, create a new team, add some scouts, and then try restoring that screen, the crash occurs.
Full stacktrace:
03-07 22:38:45.523 4489-4489/com.supercilex.robotscouter.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.supercilex.robotscouter.debug, PID: 4489
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: android.support.v7.widget.LinearLayoutManager$SavedState
at android.os.Parcel.readParcelableCreator(Parcel.java:2916)
at android.os.Parcel.readParcelable(Parcel.java:2842)
at android.os.Parcel.readValue(Parcel.java:2745)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3114)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:273)
at android.os.BaseBundle.unparcel(BaseBundle.java:226)
at android.os.BaseBundle.putBoolean(BaseBundle.java:532)
at android.support.v4.app.Fragment.setUserVisibleHint(Fragment.java:960)
at com.supercilex.robotscouter.util.ui.MovableFragmentStatePagerAdapter.instantiateItem(MovableFragmentStatePagerAdapter.kt:65)
at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1004)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1152)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:663)
at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:625)
at android.support.v4.view.ViewPager.dataSetChanged(ViewPager.java:1080)
at android.support.v4.view.ViewPager$PagerObserver.onChanged(ViewPager.java:3091)
at android.support.v4.view.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:290)
at com.supercilex.robotscouter.ui.scouting.TabPagerAdapterBase.onDataChanged(TabPagerAdapterBase.kt:95)
at com.firebase.ui.common.BaseObservableSnapshotArray.notifyOnDataChanged(BaseObservableSnapshotArray.java:180)
at com.firebase.ui.firestore.FirestoreArray.onEvent(FirestoreArray.java:94)
at com.firebase.ui.firestore.FirestoreArray.onEvent(FirestoreArray.java:21)
at com.google.firebase.firestore.zzi.onEvent(Unknown Source:16)
at com.google.android.gms.internal.zzevc.zza(Unknown Source:6)
at com.google.android.gms.internal.zzevd.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)