javareactjsreact-nativegradlegradlew

RN CLI gradle clean error: Failed to delete some children


I'm running into an issue when trying to run gradlew clean.

Here's the error I'm getting:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:clean'.
> java.io.IOException: Unable to delete directory '...\node_modules\@react-native-async-storage\async-storage\android\build'
    Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.

The only way I can solve this is to manually delete certain packages from node_modules and android\build folder, then rerun gradlew clean. I've tried to kill gradlew daemons but it didn't help.


Solution

  • Here's what helped me:
    1. Reason:

    The folder of my project was synchronized with One Drive, so every time I ran ./gradlew clean, It couldn't delete the necessary folders.
    2. Solution:
    Simply move the project to another directory that is not synced with the cloud.