skip to Main Content

My current react-native version is "0.75.2" the minimum supported Gradle version is "8.7". But i get this error

FAILURE: Build failed with an exception.

  • What went wrong:
    java.io.UncheckedIOException: Could not move temporary workspace (C:UsersHermonProductAppandroid.gradle8.7dependencies-accessors569c8b261a8a714d7731d5f568e0e5c05babae10-47615e00-381c-4912-84ed-cab1f3c2e2df) to immutable location (C:UsersHermonProductAppandroid.gradle8.7dependencies-accessors569c8b261a8a714d7731d5f568e0e5c05babae10)

Could not move temporary workspace (C:UsersHermonProductAppandroid.gradle8.7dependencies-accessors569c8b261a8a714d7731d5f568e0e5c05babae10-47615e00-381c-4912-84ed-cab1f3c2e2df) to immutable location (C:UsersHermonProductAppandroid.gradle8.7dependencies-accessors569c8b261a8a714d7731d5f568e0e5c05babae10)

even if i change the Gradle version from 8.7 to 8.5, i get the error below

{FAILURE: Build failed with an exception.

  • Where:
    Build file ‘C:UsersHermonProductAppandroidappbuild.gradle’ line: 1

  • What went wrong:
    A problem occurred evaluating project ‘:app’.

Failed to apply plugin ‘com.android.internal.version-check’.
Minimum supported Gradle version is 8.7. Current version is 8.5. If using the gradle wrapper, try editing the distributionUrl in C:UsersHermonProductAppandroidgradlewrappergradle-wrapper.properties to gradle-8.7-all.zip}

what else should i do to get gradle 8.7 as the minimum supported gradle version is 8.7 for react-native "0.75.2"

2

Answers


  1. Go to: android > build.gradle

    ext {
     ...
     ndkVersion = "26.1.10909125"  
    }
    
    repositories {
     google()
     mavenCentral()
    }
    
    dependencies {
     classpath("com.android.tools.build:gradle") // remove version if any
    }
    

    Go to: android > settings.gradle
    Add this following lines at top level

    pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
    plugins { id("com.facebook.react.settings") }
    extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
    

    Go to: android > app > build.gradle
    Add following line inside react body

    react {
      autolinkLibrariesWithApp()
    }
    

    and remove following line from bottom at app > build.gradle

    apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
    

    Go to: gradle-wrapper.properties

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

    Mac:

    cd android && ./gradlew clean
    

    Windows:

    cd android && gradlew clean
    
    Login or Signup to reply.
  2. After a week long hassle, I found the way to fix the issue.
    First things first – No need to degrade Android Gradle Version or anything. So keep working with gradle version 8.7/8.8 which is mentioned in gradle_wrapper.properties file’s distributionURL.
    Actual stuff starts here –
    Step 1: Open cmd in root/android directory of your react native project and run gradlew.bat clean (it might be gradlew clean or .gradlew clean or .gradlew.bat depending on your operating system). .bat files are batch files for windows.
    Optional: Resolve any path related or jdk version related issue if you encounter as you get it clearly in console.
    Step 2: Run the command gradlew.bat –stop. It’ll stop the running daemon.
    Step 3: Run the command gradlew.bat build and it’ll fix the issue but keep in mind that it’ll charge the significant data so be prepared.

    Once the build is successful, you can run the command
    npx react-native run android in your root directory and you’re all set.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search