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

RN upgrade 0.69.9 -> 0.73.1 Task :gradle-plugin:compileKotlin FAILED #255

Open
1 task done
Choyeongdeok opened this issue Dec 26, 2023 · 8 comments
Open
1 task done

Comments

@Choyeongdeok
Copy link

Choyeongdeok commented Dec 26, 2023

Environment

Things I’ve done to figure out my issue

Upgrading version

from 0.69.9 to 0.73.1

Description

error
(1) Class 'kotlin.~~~' was compiled with an incompatible version of kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1 (this error occured even though the version of kotlin is 1.7.10)

(2) Execution failed for task ':gradle-plugin:compileKotlin'.

A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction > Compilation error

my settings

react: 18.2.0
react-native: 0.73.1

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "25.1.8937393"
        kotlinVersion = "1.7.10"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath('com.android.tools.build:gradle')
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath('com.google.gms:google-services:4.3.10')
        classpath('com.google.firebase:firebase-crashlytics-gradle:2.7.1')
    }
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
networkTimeout=10000
validateDistributionUrl=true
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
@prakashkrsingh0
Copy link

With the same issue, I'm also suffering. Please let me know if you know of any solution to this problem.

Task :react-native-gradle-plugin:compileKotlin FAILED
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors

/node_modules/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt: (57, 42): Class 'kotlin.reflect.KClass' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
/Users/prakashkumarsingh_ttm/.gradle/wrapper/dists/gradle-8.3-all/6en3ugtfdg5xnpx44z4qbwgas/gradle-8.3/lib/kotlin-stdlib-common-1.9.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.

The class is loaded from /Users/prakashkumarsingh_ttm/.gradle/wrapper/dists/gradle-8.3-all/6en3ugtfdg5xnpx44z4qbwgas/gradle-8.3/lib/kotlin-stdlib-1.9.0.jar!/kotlin/reflect/KClass.class

@MarineP31
Copy link

I've had the same errors and it was because I'd left some files still in java. Make sure you no longer have any java files :

  • android/app/src/debug/java/com/[YOUR_APP_NAME]/ReactNativeFlipper.java => should be delete
  • android/app/src/main/java/com/[YOUR_APP_NAME]/MainActivity.java => should be modify into kotlin file
  • android/app/src/store/java/com/[YOUR_APP_NAME]/ReactNativeFlipper.java => should be delete
  • etc...

@illestomas
Copy link

illestomas commented Feb 1, 2024

my workaround was to set in gradle-wrapper.properties back to
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
and in build.gradle add kotlinVersion = "1.8.0" to buildscript.ext

@illestomas
Copy link

upgrading @react-native/gradle-plugin solves the issue as well, no need to downgrade gradle to 8.0.1

So the final configuration:

gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip

build.gradle:

kotlinVersion = "1.8.0"

package.json:

"@react-native/gradle-plugin": "0.73.4",

@gkasireddy202
Copy link

Hi,
I upgraded my project from 0.68.7 to 0.73.2. I am getting the below error on Android.
I do not want to upgrade my libraries in package.json
The project is using an incompatible version (AGP 8.1.1) of the Android Gradle plugin. Latest supported version is AGP 7.2.1.

@WinstonLeonard
Copy link

I've had the same errors and it was because I'd left some files still in java. Make sure you no longer have any java files :

  • android/app/src/debug/java/com/[YOUR_APP_NAME]/ReactNativeFlipper.java => should be delete
  • android/app/src/main/java/com/[YOUR_APP_NAME]/MainActivity.java => should be modify into kotlin file
  • android/app/src/store/java/com/[YOUR_APP_NAME]/ReactNativeFlipper.java => should be delete
  • etc...

How do we modify into kotlin file

@gkasireddy202
Copy link

I resolved this issue by changing the namespace in appname/android/app/build.gradle
namespace "com.appname"

@rrrgho
Copy link

rrrgho commented May 24, 2024

upgrading @react-native/gradle-plugin solves the issue as well, no need to downgrade gradle to 8.0.1

So the final configuration:

gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip

build.gradle:

kotlinVersion = "1.8.0"

package.json:

"@react-native/gradle-plugin": "0.73.4",

This solved my issue.

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

7 participants