stripe / stripe-terminal-react-native

React Native SDK for Stripe Terminal
https://stripe.com/docs/terminal/payments/setup-integration?terminal-sdk-platform=react-native
MIT License
95 stars 47 forks source link

Expo 50 build not working on Android #613

Closed Noitidart closed 3 months ago

Noitidart commented 5 months ago

Describe the bug Building Android with Java 17 (default build envrionment on Expo for 50), is giving this error when using Expo 50:

To Reproduce Steps to reproduce the behavior:

  1. Install lib
  2. Install expo-build-properties to up the minSdkVersion to 26 as Expo 50 by default has 23 - see https://github.com/stripe/stripe-terminal-react-native/issues/584#issuecomment-1848922273
  3. Build Android and it fails

Expected behavior Android build should work

Execution failed for task ':stripe_stripe-terminal-react-native:compileDebugKotlin'.

> 'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.

  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

* Try:

> Run with --stacktrace option to get the stack trace.

> Run with --info or --debug option to get more log output.

> Run with --scan to get full insights.

> Get more help at

https://help.gradle.org.

BUILD FAILED in 5m 31s

I already used expo-build-properties to up the minSdkVersion to 26 and tried the solution shared here - https://github.com/stripe/stripe-terminal-react-native/issues/584#issuecomment-1848922273 so my plugin is like this:

      [
        "expo-build-properties",
        {
          "android": {
            "minSdkVersion": 26,
            "compileSdkVersion": 34,
            "targetSdkVersion": 34,
            "buildToolsVersion": "34.0.0",
            "packagingOptions": {
              "exclude": ["org/bouncycastle/x509/CertPathReviewerMessages*"]
            }
          }
        }
      ],

Screenshots Please see error logs

Stripe Terminal React Native SDK version

"@stripe/stripe-terminal-react-native": "^0.0.1-beta.15",

Smartphone (please complete the following information):

Not applicable

Additional context

No

Noitidart commented 5 months ago

I think this might be related to improperly upgrading to Expo 50.

Noitidart commented 5 months ago

Correct, I upgraded improperly, closing.

Noitidart commented 5 months ago

Actually I'm wrong, it's not due to Expo 50 upgrade. Here's the error, will edit it up in the first post:

Execution failed for task ':stripe_stripe-terminal-react-native:compileDebugKotlin'.

> 'compileDebugJavaWithJavac' task (current target is 17) and 'compileDebugKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.

  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

* Try:

> Run with --stacktrace option to get the stack trace.

> Run with --info or --debug option to get more log output.

> Run with --scan to get full insights.

> Get more help at

https://help.gradle.org.

BUILD FAILED in 5m 31s
Noitidart commented 5 months ago

Re-opening, I tried everything, and can't get this to build on Expo 50.

KillianLarcher commented 5 months ago

I have exactly the same problem. No solution found.

RambokDev commented 5 months ago

I had the same problem, the only solution that i found is downgrading to Expo 49. Do not hesitate to test my projet, i created a simpler Tap to Pay React Native app in order to test the stripe terminal SDK. https://github.com/RambokDev/stripe-tap-to-pay-react-native

Noitidart commented 5 months ago

I had the same problem, the only solution that i found is downgrading to Expo 49. Do not hesitate to test my projet, i created a simpler Tap to Pay React Native app in order to test the stripe terminal SDK. https://github.com/RambokDev/stripe-tap-to-pay-react-native

Thanks very much I will try that. I had downgraded expo to 49 but it wasn't building on expo pipeline. Did you try that? You used beta 15 of lib I see which is very interesting. I thought I tried expo 49 and beta 15 but expo build cloud wouldn't work.

I think the problem I had was a bunch of libs weren't ready for Java 17 like flash list. I might have to try expo 49, terminal beta 14, and use a non 17 image for Expo build.

KillianLarcher commented 5 months ago

I had the same problem, the only solution that i found is downgrading to Expo 49. Do not hesitate to test my projet, i created a simpler Tap to Pay React Native app in order to test the stripe terminal SDK. https://github.com/RambokDev/stripe-tap-to-pay-react-native

Thanks very much I will try that. I had downgraded expo to 49 but it wasn't building on expo pipeline. Did you try that? You used beta 15 of lib I see which is very interesting. I thought I tried expo 49 and beta 15 but expo build cloud wouldn't work.

I think the problem I had was a bunch of libs weren't ready for Java 17 like flash list. I might have to try expo 49, terminal beta 14, and use a non 17 image for Expo build.

I managed to build on expo server with this image : ubuntu-22.04-jdk-17-ndk-r21e.

You can change the image in eas.json by adding the following in a profile : "android": { "image": "ubuntu-22.04-jdk-17-ndk-r21e" }

RambokDev commented 5 months ago

I had the same problem, the only solution that i found is downgrading to Expo 49. Do not hesitate to test my projet, i created a simpler Tap to Pay React Native app in order to test the stripe terminal SDK. https://github.com/RambokDev/stripe-tap-to-pay-react-native

Thanks very much I will try that. I had downgraded expo to 49 but it wasn't building on expo pipeline. Did you try that? You used beta 15 of lib I see which is very interesting. I thought I tried expo 49 and beta 15 but expo build cloud wouldn't work. I think the problem I had was a bunch of libs weren't ready for Java 17 like flash list. I might have to try expo 49, terminal beta 14, and use a non 17 image for Expo build.

I managed to build on expo server with this image : ubuntu-22.04-jdk-17-ndk-r21e.

You can change the image in eas.json by adding the following in a profile : "android": { "image": "ubuntu-22.04-jdk-17-ndk-r21e" }

Yes, this worked for me also :)

eeynard commented 5 months ago

Hey ! the build.gradle file needs some updates in order to follow Expo 50 migration directions. In the changelog they say :

If you maintain any Expo Modules:
For Android: update your library build.gradle to match the changes in [this diff](https://gist.github.com/brentvatne/61cd1a938fb4ba8869bc490647aa52e8). You may also now remove the JVM target version configuration, [as explained in this FYI page](https://expo.fyi/expo-modules-gradle8-migration#error-task-current-target-is-17-and-compilereleasekotlin-task-current-target-is-11-jvm-target-compatibility-should-be-set-to-the-same-java-version).
For iOS: update the platform deployment target field from '13.0' to '13.4', matching the changes in [this diff](https://gist.github.com/brentvatne/87ac1b2c402be415972231a73ba3a695).

For those who are interested, in the meantime, here is the patch file :

patches/@stripe+stripe-terminal-react-native+0.0.1-beta.15.patch

diff --git a/node_modules/@stripe/stripe-terminal-react-native/android/build.gradle b/node_modules/@stripe/stripe-terminal-react-native/android/build.gradle
index eacd4f6..f31dc04 100644
--- a/node_modules/@stripe/stripe-terminal-react-native/android/build.gradle
+++ b/node_modules/@stripe/stripe-terminal-react-native/android/build.gradle
@@ -50,12 +50,16 @@ android {
     lintOptions {
         disable 'GradleCompatible'
     }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_8
-        targetCompatibility JavaVersion.VERSION_1_8
-    }
-    kotlinOptions {
-        jvmTarget = "1.8"
+    def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
+    if (agpVersion.tokenize('.')[0].toInteger() < 8) {
+        compileOptions {
+            sourceCompatibility JavaVersion.VERSION_11
+            targetCompatibility JavaVersion.VERSION_11
+        }
+
+        kotlinOptions {
+            jvmTarget = JavaVersion.VERSION_11.majorVersion
+        }
     }
 }
Noitidart commented 5 months ago

Thank you for that! I downgraded to 49 for now as I was getting a crash on initialize on ios. But will try this out if I can get past that, thank you!

dakkor71 commented 4 months ago

@nazli-stripe Could you please take a look and give some advice on how to handle this issue?

isaachinman commented 4 months ago

This issue is currently blocking our org. Hoping for a quick resolution.

Noitidart commented 4 months ago

If you're blocked I recommend downgrading to Expo 49, but I understand it's a problem. When downgrade many libs don't build anymore. I created a new project and removed things like FlashList.

isaachinman commented 4 months ago

Obviously downgrading to Expo v49 is an option, but Stripe is a for-profit company and it seems like a small ask to support Java 17. The patch diff is very small and this fix should frankly be released ASAP. cc @nazli-stripe

Noitidart commented 4 months ago

I understand. Expo v49 isn't an option for everyone. I had to sacrifice other libraries, and lost stuff I needed, but Stripe was core functionality so I made the trade off.

isaachinman commented 4 months ago

@ianlin-bbpos Can we get an official response?

nazli-stripe commented 4 months ago

We recently merged https://github.com/stripe/stripe-terminal-react-native/pull/616 to address compatibility issues for Java 17. We are trying to get a new release out as soon as possible, and will address the Expo issues in that. I will update this issue with any new information.

dakkor71 commented 4 months ago

@nazli-stripe Thanks!

yaromyrshmid commented 4 months ago

@nazli-stripe Hi.

Are there any updates on new release date?

Thanks.

dakkor71 commented 4 months ago

Hello @nazli-stripe,

any update?

Thanks!

isaachinman commented 4 months ago

So, "as soon as possible" means more than three weeks?

s-scratch commented 3 months ago

Any update on the next release. Running into the issue (non-Expo project). Tried downgrading to 13 and get different error

christian-unwrittenhair commented 3 months ago

Try this. https://github.com/christian-unwrittenhair/stripe-terminal-react-native

nazli-stripe commented 3 months ago

hey everyone, we just released a new version that should address compatibility issues for Java 17: https://github.com/stripe/stripe-terminal-react-native/releases/tag/v0.0.1-beta.16

let us know if you are still running into issues

dakkor71 commented 3 months ago

Hey @nazli-stripe!

I'm not an expert in maintaining 3rd party packages but after bumping to v0.0.1-beta.16 I'm getting error:

TS2307: Cannot find module @stripe/stripe-terminal-react-native or its corresponding type declarations.

I noticed that the new version is missing the lib folder which contains the typescript configuration. (Checked it also in a new fresh project and the result is the same.)

Any thoughts?

Best

s-scratch commented 3 months ago

I had same issue as @dakkor71

isaachinman commented 3 months ago

@nazli-stripe Can we please get a response?

Two users reported feedback – that the build you released is broken – and we've had no response in five days. Even if you are not able to action the issue immediately, an acknowledgement would be a good place to start.

Many of us in this thread have been waiting months.

nazli-stripe commented 3 months ago

hey @isaachinman sorry i missed the discussion on this post, repeating the response on the new issue for specific Expo bug on beta.16 https://github.com/stripe/stripe-terminal-react-native/issues/650:

we are aware of this issue and have merged https://github.com/stripe/stripe-terminal-react-native/pull/652 to address it. We are targeting a release this week to fully resolve it

nazli-stripe commented 3 months ago

we just released https://github.com/stripe/stripe-terminal-react-native/releases/tag/v0.0.1-beta.17 to address this issue

nazli-stripe commented 3 months ago

closing this as Expo 50 now works with beta.17, feel free to open a new one if people are still running into issues

dakkor71 commented 3 months ago

@nazli-stripe I can confirm that beta.17 works well with EXPO50. Thanks!