Adyen / adyen-react-native

Adyen React Native
https://docs.adyen.com/checkout
MIT License
42 stars 32 forks source link

2.1.0 - Android getting "Task :adyen_react-native:compileReleaseKotlin FAILED" #485

Open simonarcher opened 1 week ago

simonarcher commented 1 week ago

Describe the bug At the moment I have the @adyen/react-native package of 2.0.1 running fine.

However, when I try and update to the latest 2.1.0 of the package I get the following error when trying to compile my Android application

Execution failed for task ':adyen_react-native:compileReleaseKotlin'.
> Inconsistent JVM-target compatibility detected for tasks 'compileReleaseJavaWithJavac' (17) and 'compileReleaseKotlin' (1.8).

And Im not entirely sure how to resolve this.

my build.gradle file looks like this

buildscript {
    ext {
        buildToolsVersion = '34.0.0'
        minSdkVersion = 26
        compileSdkVersion = 34
        targetSdkVersion = 34
        supportLibVersion = "27.1.1"
        googlePlayServicesVersion = "16.+"
        googlePlayServicesAuthVersion = "19.2.0"
        kotlinVersion = "1.9.22"

        ndkVersion = "26.1.10909125"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.gms:google-services:4.4.2'
        classpath 'com.google.firebase:perf-plugin:1.4.2'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
    }
}

allprojects {
    repositories {
        maven {
            url("$rootDir/../node_modules/detox/Detox-android")
        }
        google()
        // add in-app messaging dependency
        maven { url 'https://maven.gist.build' }
    }
}

subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

 wrapper {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

apply plugin: "com.facebook.react.rootproject"

And this only seems to be happening on 2.1.0 update and 2.0.1 seems fine, and I cant seem to identify in breaking change or updates I may need to do from the release notes.

any help or guidance on this would be most appreciated! :)

thanks!

descorp commented 1 week ago

Hey @simonarcher

What version of React Native, Expo(if any), Android Studio, Java, Gradle Wrapper you are using?

In 2.1.0 we have specified jvmTarget. It was intended to fix exactly the issue you are getting 😅

simonarcher commented 1 week ago

@descorp thanks for the quick reply!

So to answer your questions

Screenshot 2024-07-03 at 14 03 42

descorp commented 1 week ago

hm.. tomorrow I will try to replicate your setup to see if I can reproduce this issue. In a meanwhile, could you try removing following lines from ../node_modules/@adyen/react-native/android/build.gradle:

    kotlinOptions {
        jvmTarget = "1.8"
    }
simonarcher commented 1 week ago

cool will give that a try in the meantime and let you know the results... :)

devic021 commented 1 week ago

Hey guys

I also had a same issue with latest version and had to remove that part that is added to be able to build android app.

Removed this as a temp solution and after that i can build the app again:

kotlinOptions {
 jvmTarget = "1.8"
}
simonarcher commented 1 week ago

hm.. tomorrow I will try to replicate your setup to see if I can reproduce this issue. In a meanwhile, could you try removing following lines from ../node_modules/@adyen/react-native/android/build.gradle:

    kotlinOptions {
        jvmTarget = "1.8"
    }

Yeah can also confirm removing this has allowed me to compile the app successfully with no issues. ☺️

descorp commented 1 week ago

Thanks @devic021 @simonarcher 💚

We will investigate how to make this work for everyone!

zegenerative commented 2 days ago

I have the same issue but then with

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

Expo SDK 50

removing the kotlinOptions worked

descorp commented 2 days ago

Thanks @zegenerative

We observe this problem for RN 74+ and working on making support for both old and new versions.

descorp commented 1 day ago

Released 2.1.1. It should resolve the issue and provide "some" backward compatibility

devic021 commented 1 day ago

@descorp

Thanks, i will test it right away!

viru-rathore commented 1 day ago

I am using following package configuration, but still getting this error.

    "@adyen/react-native": "2.1.1",
    "react": "18.2.0",
    "react-native": "0.72.6",

FAILURE: Build failed with an exception.

descorp commented 10 hours ago

Hey @viru-rathore

This is the opposite error :)

If we keep jvmTarget = "1.8":

Inconsistent JVM-target compatibility detected for tasks 'compileReleaseJavaWithJavac' (17) and 'compileReleaseKotlin' (1.8).

If we remove it:

Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'compileDebugKotlin' (17).

Could you check if 2.1.0 will work for you?


Consider using JVM Toolchain

Unfortunately, to use Gradle toolchain support, one must use the Android Gradle plugin (AGP) version 8.1.0-alpha09 or higher. As you might know default gradle version for RN is 7.3.1


Could you list your:

descorp commented 2 hours ago

FYI I can confirm that our latest "Adyen Android SDK" only works on React-Native 0.73+ due to android target limitation.

To make this work for RN 0.72 and below, one needs to: