androidreact-nativekotlinbuild.gradle

React-native 0.76.7 - org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction


A few days ago I've updated react-native to 0.76.7 version and I can't build and run android version, when iOS works properly. I always encounter this error:

e: file:///Users/marcelina/.gradle/caches/8.10.2/transforms/1258208f462649e4068633c595a67e2a/transformed/play-services-measurement-api-22.2.0-api.jar!/META-INF/java.com.google.android.gmscore.integ.client.measurement_api_measurement_api.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.
e: file:///Users/marcelina/.gradle/caches/8.10.2/transforms/28d19078ed3a76b20e94df2c3463b9c5/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/java.com.google.android.gms.libs.filecompliance.proto_file_access_api_type_kt_proto_lite.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.
e: file:///Users/marcelina/.gradle/caches/8.10.2/transforms/28d19078ed3a76b20e94df2c3463b9c5/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_only_for_use_in_proto_generated_code_its_generator_and_tests.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.
e: file:///Users/marcelina/.gradle/caches/8.10.2/transforms/28d19078ed3a76b20e94df2c3463b9c5/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_shared_runtime.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.9.0.

Reset cache, .gradlew clean, reinstall node_modules give's nothing.

Here is my build.gradle:

buildscript {
    ext {
        buildToolsVersion = "35.0.0"
        minSdkVersion = 24
        compileSdkVersion = 35
        targetSdkVersion = 34
        ndkVersion = "26.1.10909125"
        kotlinVersion = "1.9.25"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
        classpath('com.google.gms:google-services:4.4.2')
        classpath('com.google.firebase:firebase-crashlytics-gradle:3.0.3')
    }

}

allprojects {
    repositories {
        maven {
          url("$rootDir/../node_modules/detox/Detox-android")
        }
    }
}


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

and gradle.properties:

org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=512m

android.useAndroidX=true

reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

newArchEnabled=true
hermesEnabled=true

Have anyone had a similar error?


Solution

  • Recently had this issue, upgrading to react-native: 0.77.0 seems to be fixing or downgrading your react-native to the earlier version: 0.76.1

    But the issue with adding 0.77.0 is that expo v52 and higher requires 0.76.7. The other fix was to use npm i @react-native/gradle-plugin