Status Update
Comments
ze...@google.com <ze...@google.com>
ze...@google.com <ze...@google.com> #2
Thanks for reporting your issue!
It appears that the new API additions have introduced these additional checks using reflection. The APIs on Parcel
are:
readList(java.util.List, ClassLoader, Class<T>);
readParcelable(ClassLoader, Class<T>);
readParcelableCreator(ClassLoader, Class<T>);
In your case it is the readParcelable
call that is triggering this new path.
There are two ways you can workaround the issue:
- Rewrite the code to avoid using the new APIs listed above.
- Amend you keep rules to ensure the expected inner/outer relation that is being reflected on is kept.
For workaround 2. you can use these which are the minimal rules that should retain the required info:
# Parcel reading may lookup/validate the parcel and creator via their
# inner-class relationship. Ensure the attributes are kept and the
# inner/outer relationship is soft pinned. The 'allowshrinking' option
# allows the classes to be removed if unused, but otherwise their attributes
# are retained.
-keepattributes EnclosingClass,InnerClasses
-keep,allowshrinking,allowobfuscation class * implements android.os.Parcelable {}
-keep,allowshrinking,allowobfuscation class * implements android.os.Parcelable$Creator {}
In your case, the -keepattributes
are already kept by existing rules, but I included it here for completeness.
Closing this as intended behavior, but let us know if the above workarounds don't work and we will reopen it.
my...@gmail.com <my...@gmail.com> #3
Thank you. Workaround 2 works and only increases the apk by 5KB. For workaround 1, the alternative APIs are marked as deprecated in framework. Should this be addressed in r8/framework somewhere though instead of closing this as intended behavior?
ze...@google.com <ze...@google.com> #4
Good to hear!
I've filed an internal issue to discuss potential resolutions of this (
Likely we will need to distribute the rules in
ze...@google.com <ze...@google.com> #5
After more discussion it looks like the best way to resolve this issue is to use the androidx compat layer. They have implemented a fix to avoid calling the API on T devices in androidx.core:1.10.0-alpha01
.
Could you try updating the use of android.os.Parcel.readParcelable
in your utils class to instead use androidx.core.os.ParcelCompat.readParcelable
and ensure you have a dependency on a recent androidx.core
(eg., 1.10.0-rc1).
With that you should be able to remove the keep rules again.
my...@gmail.com <my...@gmail.com> #6
I see that this API is already fixed on Android U. Thanks!
ze...@google.com <ze...@google.com> #7
Yes, the underlying issue is fixed in U, but it will remain an issue for T devices. So if your app is targeting devices that could include T then the compat lib is the best fix.
my...@gmail.com <my...@gmail.com> #8
Unfortunately workaround 2 did not fix the NPE for some reason. (It did kept the enclosing class relationship though looking at decompiled apk.) I guess I will try workaround 1 next.
le...@gethomesafe.com <le...@gethomesafe.com> #9
I am experiencing a similar issue when using Intent::getParcelableExtra
in some custom ActivityResultContract
s. Does IntentCompat.getParcelableExtra
also prevent this issue from happening?
ze...@google.com <ze...@google.com> #10
The compat indirections should workaround the issue for you. Let us know if it does not work.
ri...@ffw.com <ri...@ffw.com> #11
Can you please also add this Android U+ change to BundleCompat.getParcelable?
ze...@google.com <ze...@google.com> #12
As far as I can tell the implementation of BundleCompat.getParcelable
has the correct check for API 34 to avoid the incorrect implementation shipped in 33. Are you seeing this issue when using BundleCompat.getParcelable
?
ri...@ffw.com <ri...@ffw.com> #13
I was looking at an old version, seems to be fixed, yes (sorry for the inconvenience)
Description
Source code:https://github.com/Mygod/pogoplusle/tree/v1.0.1
Compiled app: https://github.com/Mygod/pogoplusle/releases/download/v1.0.1/pogoplusle-v1.0.1.apk (freedomRelease variant)
To see this issue, decompile this app, and navigate to be.mygod.librootkotlinx.ParcelableBoolean. It can be seen that in the static constructor,
CREATOR = new FragmentState.AnonymousClass1(20);
where all the parcelable creators are merged into that anonymousclass1.This seems to cause trouble withhttps://cs.android.com/android/platform/superproject/+/android-13.0.0_r1:frameworks/base/core/java/android/os/Parcel.java;l=4850;drc=b6ac4a054b165831933186cec3c9845e27d76140 )
readParcelable
. In particular,readParcelableCreatorInternal
has the following code: (In this case, the enclosing class will be changed to something else. From Crashlytics, I can see crashes like this on a Pixel 6 Pro Android 13:
Is there a way to opt out of this optimization, or at least for Parcelables?