stripe-react-native: Google Pay: Missing annotations
Describe the bug
Android builds fail because of an annotations error. I am migrating a react-native project to a monorepo managed with nx. It seems like a misconfiguration related to gradle and linting. The project builds after I remove the @stripe/stripe-react-native package
.
This does not occur if I install the package on a new project with the react-native cli.
I have tried tweaking the gradle versions, but continue to run into this. Could someone please provide pointers to resolving this.
> Task :stripe_stripe-react-native:packageDebugResources FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
58 actionable tasks: 2 executed, 56 up-to-date
ERROR:/Users/esfxra/monorepo/apps/test-app/node_modules/@stripe/stripe-react-native/android/src/main/res/layout/googlepay_button_dark.xml: Resource and asset merger: /Users/esfxra/monorepo/apps/test-app/node_modules/@stripe/stripe-react-native/android/src/main/res/layout/googlepay_button_dark.xml is not annotated as @Input
java.lang.IllegalStateException: /Users/esfxra/monorepo/apps/test-app/node_modules/@stripe/stripe-react-native/android/src/main/res/layout/googlepay_button_dark.xml is not annotated as @Input
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':stripe_stripe-react-native:packageDebugResources'.
> /Users/esfxra/monorepo/apps/test-app/node_modules/@stripe/stripe-react-native/android/src/main/res/layout/googlepay_button_dark.xml: Error: is not annotated as @Input
To Reproduce Steps to reproduce the behavior:
- Run
npm install @stripe/stripe-react-native
- Integrate the
<StripeProvider>{...}</StripeProvider>
component - Run
npx nx run wifi-app:run-android
- See error
This is a repo scaffolded with nx where the error can be reproduced [RN 0.69]:
And this is a repo scaffolded by the react-native cli with no errors [RN 0.69]:
Expected behavior N/A
Screenshots N/A
Desktop (please complete the following information): N/A
Smartphone (please complete the following information):
- Device: Pixel 3
- OS: Android
Additional context N/A
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 48 (3 by maintainers)
I’ve fixed this issue by using
patch-package
to patch the@react-native-community/cli-platform-android
package so it loads the dependencies from the rootnode_modules
folder. The issue definitely seems to be related to symlinks, which gradle doesn’t know how to handle (at least it seems that way from my research). Here’s the patch:Can this be reopened, only package that has this issue
I approached this issue with this patch;
Delete the layout folder
node_modules/@stripe/stripe-react-native/android/src/main/res/layout
Comment the layouts inside
initialize()
method ofnode_modules/@stripe/stripe-react-native/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt
build.gradle
file, just comment them.patch.sh
and assign 777 permission,sudo chmod +x patch.sh
patched_node_modules/@stripe/stripe-react-native/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt
postinstall
script insidepackage.json
That’s it now until the Stripe team fixes this issue, we can survive.
I have just started investigating, and it seems like the issue is indeed related to Gradle and the .xml files not being inside the root project (but only symlinked there).
As mentioned above, removing the .xml files and their references fixes the build.
Simple Patch
I won’t be able to get to this super soon, but hope to debug it eventually. I’m curious if this only affects stripe-react-native, or is a more widespread issue with
.xml
assetsI used this patch on my project which is a mono repo by Nx, It solved the Stripe issue but causes another issue for ‘react-native-gesture-handler’
[react-native-gesture-handler] Multiple versions of Gesture Handler were detected. Only one instance of react-native-gesture-handler can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-gesture-handler/docs/troubleshooting#multiple-instances-of-gesture-handler-were-detected
I followed the react-native-gesture-handler approach in their documentation to resolve this issue too, but did not work!
That patch does not work in our case
Hi @retro @andreacab2, how you guys can make it work? I tried the solution but it doesn’t work in my case
Same issue here. Any news about this ?
Closing this for now since it seems like an issue with
nx
. Hope to hear back from them in that issue linked above, and if there are actionable changes on our end to make, happy to follow up and take care of thatHi, I have the same problem since I tried to upgrade to react native 0.69. I also use nx but Gradle 7.