stripe-react-native
stripe-react-native copied to clipboard
Android: R8 Minifying missing classes ERROR
Describe the bug Production build of android fails with error:
> Task :app:minifyReleaseWithR8 FAILED
AGPBI: {"kind":"error","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in X/android/app/build/outputs/mapping/release/missing_rules.txt.","sources":[{}]}
AGPBI: {"kind":"error","text":"Missing class com.stripe.android.pushProvisioning.PushProvisioningActivity$g (referenced from: void com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy$createActivityEventListener$listener$1.onActivityResult(android.app.Activity, int, int, android.content.Intent))\nMissing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider))\nMissing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error (referenced from: void com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy$createActivityEventListener$listener$1.onActivityResult(android.app.Activity, int, int, android.content.Intent))\nMissing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider))\nMissing class com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider) and 1 other context)","sources":[{}],"tool":"R8"}
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in X/android/app/build/outputs/mapping/release/missing_rules.txt.
Missing class com.stripe.android.pushProvisioning.PushProvisioningActivity$g (referenced from: void com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy$createActivityEventListener$listener$1.onActivityResult(android.app.Activity, int, int, android.content.Intent))
Missing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider))
Missing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error (referenced from: void com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy$createActivityEventListener$listener$1.onActivityResult(android.app.Activity, int, int, android.content.Intent))
Missing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider))
Missing class com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider) and 1 other context)
ASM Instrumentation process wasn't able to resolve some classes, this means that
the instrumented classes might contain corrupt stack frames. Make sure the
dependencies that contain these classes are on the runtime or the provided
classpath. Otherwise, the jvm might fail to load the corrupt classes at runtime
when running in a jvm environment like unit tests.
Classes that weren't resolved:
> com.google.common.util.concurrent.ListenableFuture
To Reproduce Steps to reproduce the behavior:
- Create RN repo with RN version 0.74.1
- Install "@stripe/stripe-react-native": "^0.38.1",
- Add Provider component
- Run Android prod build
- See error
Expected behavior App is built without error
Additional context Integration works properly on both android and iOS emulators in debug mode, no errors or warnings. iOS Prod build works fine as well.
I am from the R8 team, and this looks like a missing dependency. The classes mentioned are references in the input, but not present. If these classes are in an optional dependency, then adding the rules generated in X/android/app/build/outputs/mapping/release/missing_rules.txt to your proguardFiles (see https://developer.android.com/build/shrink-code#enable) should work.
Thanks @sgjesse I've made it as a workaround right away I do however expect stripe team to look into it to either fix or adjust troubleshooting section to include info about that!
can you guys show the changes made to make it work? I'm stuck here
@Orteu adding
-dontwarn com.stripe.**
will silence R8 warnings that became errors in AGP 8+
While adding -dontwarn is a workaround, the stripe team should ensure that these are not present when depending on the library. Either by adding explicit -dontwarn 's to the consumer keep runes (if this is by design optional dependencies) or add the required transitive dependencies to the POM.
Im using react native expo and anyone can help me on how can i resolve this?? @sgjesse where i need to add -dontwarn in my react native expo application can you share that info please?
I am not familiar with the Expo project setup, and cannot give any info on where Proguard configuration rules are located.
@udayaprakashjayaraman Were you able to fix this?
@udayaprakashjayaraman Were you able to fix this?
@divyanshu-bantr with a workaround, I created new project and replaced my existing code on that and installed required packages and it started working for me.
@udayaprakashjayaraman What version of stripe-react-native are you using for the new project?
Edit - I upgraded my expo project to SDK50 and this has been an issue ever since, seems like this version is the compatible one but the issue still remains. I also tried 0.37.0, no luck
Quick fix - I removed these valuesenableProguardInReleaseBuilds: true and enableShrinkResourcesInReleaseBuilds: true, from the expo-build-properties plugin in app.config
This isn't perfect since minifying step does not occur and the final build is larger in size. Also, this is avoiding the errors rather than fixing them
Where you able to fix this? having the same issue with expo managed project
@bkjp-dev I have disabled Proguard in release builds for now. Not ideal and the google play console also gives a warning when you upload the aab. It is what it is for now..
Im using react native expo and anyone can help me on how can i resolve this?? @sgjesse where i need to add -dontwarn in my react native expo application can you share that info please?
This is how I resolved the issue in Expo app.json:
"expo-build-properties",
{
"android": {
"enableProguardInReleaseBuilds": true,
"enableShrinkResourcesInReleaseBuilds": true,
"extraProguardRules": "-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g -dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args -dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error -dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter -dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider"
}
}
Credits to https://github.com/flutter-stripe/flutter_stripe/issues/1546 and https://www.reddit.com/r/reactnative/comments/wy861j/set_proguard_rules_in_expo_project/