react native build issue on java version21 and android gradle 8.5 : Build failed with an exception

452 Views Asked by At

I have tried to run may app on java version 21 and android gradle 8.5 but it show an error message. same error shows when i try "./gradlew clean" . this app works before but i have forgotten my java version then so i thought of just upgrading it.

build.gradle settings:

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        kotlinVersion = "1.6.20"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"

        VisionCameraCodeScanner_targetSdkVersion = 31 //add
        VisionCameraCodeScanner_compileSdkVersion = 31 //add
    }
    
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath 'com.google.android.gms:strict-version-matcher-plugin:1.2.1' 
        // implementation project(':react-native-share')
        // implementation 'com.swmansion.reanimated:react-native-reanimated:3.2.0'
    }
    allprojects {
    repositories {

        // * Your other repositories here *

        // * Add a new maven block after other repositories / blocks *
        maven {
            // expo-camera bundles a custom com.google.android:cameraview
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
    }
}
}

wrapper {
    gradleVersion = '8.5'
}

error message:

  • What went wrong: Execution failed for task ':react-native-gradle-plugin:compileKotlin'.

Compilation error. See log for more details

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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

1

There are 1 best solutions below

1
On

Android is using Gradle build system. That build script dependency is Gradle plugin to interact (compile, test, etc) with the Android Build Tools. That line declares that your project require Android's Gradle plugin version 7.3.1 com.android.tools.build:gradle:7.3.1

you can openyour project in android studio for download and sync your gradle version to 8.5

;)