Search code examples
react-nativegradle

How to solve UncheckedIOException Error on ReactNative Setup?


I'm setting React Native up for an android project. i had installed all dependencies and checked by npx react-native doctor and this is the doctor's result:

Common
 ✓ 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

now in terminal I use npx react-native run-android command to run my sample project but i get this error:

BUILD FAILED in 23s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * Where: Settings file 'D:\Projects\AwesomeProject\android\settings.gradle' line: 2 * What went wrong: Error resolving plugin [id: 'com.facebook.react.settings'] > java.io.UncheckedIOException: Could not move temporary workspace (D:\Projects\AwesomeProject\android\.gradle\8.10.2\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-dd285373-4e2a-49c9-8a20-5145657540c5) to immutable location (D:\Projects\AwesomeProject\android\.gradle\8.10.2\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10) * 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 23s.

I saw in a youtube video that I should open the project in android studio once then this error would be solved but again I'm getting same error there:

enter image description here

I had tried to delete caches folder in .gradle directory also changed gradle folders access to full.

please anyone help me and community to solve this problem, I would buy him a coffee.


Solution

  • Solved after 12 days conflict to setup react native and no answer in community.

    run these steps:

    1. run npx react-native doctor
    2. be sure you pass all doctor items
    3. open terminal and go to you project directory
    4. cd android
    5. run rd /s /q .gradle
    6. run npx react-native run-android