stripe-terminal-react-native: Expo 50 build not working on Android

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 32

Most upvoted comments

I have exactly the same problem. No solution found.

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
+        }
     }
 }

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.

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

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" }