Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native run-android randomly not able to delete or create folder

I am running on Windows 10:

Permission to the folder is Everyone & Full Access.

Cmd line is set to Administrator.

--version react-native-cli: 2.0.1

--version react-native: 0.47.2

* What went wrong:
Execution failed for task ':@myApp/react-native-spinkit:mergeReleaseResources'.
> java.io.IOException: Could not delete path 'C:\Users\My\Desktop\App\node_modules\@myApp
\react-native-spinkit\android\build\intermediates\res\merged\release\drawable-xhdpi-v4'.

For example, I will get the error above. Sometimes it says could not delete some intermediate path, sometimes, it says it could not create them.

It is not a fixed error output, intermediate folders that got into trouble is different every time. When I repeat React-native run-android on the good days 2-3 times, it will compile successfully. On the bad days I will repeat the cmd 10-15 times, then it suddenly works.

By the way, I use android/gradlew clean command to make sure it does the cleaning, too.

One thing I noticed is that every time it fails the compile percentage % gets a bit further. Until the end if I see 100% then it will work.

The same code compiles in one go with Mac, android physical or virtual machine, same thing on Mac is very stable. This problem only happens with my Windows setup. Anyone experiencing the same thing as me? Is there anything I can do to fix this issue?

like image 233
Tom Avatar asked Oct 17 '17 05:10

Tom


2 Answers

You can try this: Error:Execution failed for task ':app:processDebugResources'. > java.io.IOException: Could not delete folder "" in android studio

Deleting the /build folder did it for me.

I guess some of the files in the target build directory is open in another tool you use. Just a file handle open in the folder which has to be cleaned. The build task 'clean' wants to delete all the files in the build directory(normally 'target') and when it fails, the build fails.

like image 101
emmaielle Avatar answered Oct 20 '22 19:10

emmaielle


This worked for me: cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug

like image 23
Princewill Iroka Avatar answered Oct 20 '22 19:10

Princewill Iroka