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: R8 Minifying missing classes ERROR #1700

Open
MichalSmaliraITM opened this issue Jul 29, 2024 · 10 comments
Open

Android: R8 Minifying missing classes ERROR #1700

MichalSmaliraITM opened this issue Jul 29, 2024 · 10 comments

Comments

@MichalSmaliraITM
Copy link

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:

  1. Create RN repo with RN version 0.74.1
  2. Install "@stripe/stripe-react-native": "^0.38.1",
  3. Add Provider component
  4. Run Android prod build
  5. 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.

@sgjesse
Copy link

sgjesse commented Jul 30, 2024

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.

@MichalSmaliraITM
Copy link
Author

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!

@Orteu
Copy link

Orteu commented Aug 17, 2024

can you guys show the changes made to make it work? I'm stuck here

@MichalSmaliraITM
Copy link
Author

@Orteu adding

-dontwarn com.stripe.**

will silence R8 warnings that became errors in AGP 8+

@sgjesse
Copy link

sgjesse commented Aug 20, 2024

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.

@udayaprakashjayaraman
Copy link

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?

@sgjesse
Copy link

sgjesse commented Aug 26, 2024

I am not familiar with the Expo project setup, and cannot give any info on where Proguard configuration rules are located.

@divyanshu-bantr
Copy link

@udayaprakashjayaraman Were you able to fix this?

@udayaprakashjayaraman
Copy link

udayaprakashjayaraman commented Sep 17, 2024

@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.

@divyanshu-bantr
Copy link

divyanshu-bantr commented Sep 17, 2024

@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

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

No branches or pull requests

5 participants