Failed to install react-native app

Hello everyone, I’m trying react-native for the first time. After following the offcial docs here’s what I get as error:

BUILD FAILED in 1s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong: java.io.UncheckedIOException: Could not move temporary workspace (C:\projects\reactnative\AwesomeProject\android\.gradle\8.6\dependencies-accessors\423f0288fa7dffe069445ffa4b72952b4629a15a-ef3d3344-5e3e-4d9d-865c-106f717d5fc3) to immutable location (C:\projects\reactnative\AwesomeProject\android\.gradle\8.6\dependencies-accessors\423f0288fa7dffe069445ffa4b72952b4629a15a) > Could not move temporary workspace (C:\projects\reactnative\AwesomeProject\android\.gradle\8.6\dependencies-accessors\423f0288fa7dffe069445ffa4b72952b4629a15a-ef3d3344-5e3e-4d9d-865c-106f717d5fc3) to immutable location (C:\projects\reactnative\AwesomeProject\android\.gradle\8.6\dependencies-accessors\423f0288fa7dffe069445ffa4b72952b4629a15a) * 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. BUILD FAILED in 1s.

And here is what npx react-native doctor outputs:

 ✓ Node.js - Required to execute JavaScript code
 ✓ npm - Required to install NPM dependencies
 ✓ Metro - Required for bundling the JavaScript code

Android
 ✓ Adb - Required to verify if the android device is attached correctly
 ✓ JDK - Required to compile Java code
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation
 ✓ Gradlew - Build tool required for Android builds
 ✓ Android SDK - Required for building and installing your app on Android

Errors:   0
Warnings: 0

I kindly ask for help.

have u found the solution? if u found can u share it here

hi friend. I just got the same error and was able to solve it by changing just one character.

you need to change the gradle version.
your price is 8.6 or 8.7. Lower it to 8.5

change gradle wrapper properties :
YourApp/android/gradle/wrapper/gradle-wrapper.properties : distributionUrl=https://services.gradle.org/distributions/gradle-8.5-all.zip

1 Like

According to "Immutable workspace contents have been modified" failure when workspace contents are not modified · Issue #28475 · gradle/gradle · GitHub this might be caused by an Anti-Virus disturbing.

thanks it worked for me. It took days to figure out