React Native: always clear the tower before running run-native-run-android

If you do not run cd android && ./gradlew clean before react-native run-android , this fails with some error, for example:

Failed to create folder: ...

or

Failed to delete folder: ...

so I have to run again to solve the problem.

Help me solve it without gradlew clean , please.

Many thanks.

+14
source share
4 answers

I had a similar problem since upgrading to RN 43. I have not yet found a solution, but I realized that a pure necessity will occur before a successful build.

The best solution for me so far is a batch script to run a project that includes gradlew clean

 @echo on cd (path to project/android folder) && ^ gradlew clean && ^ cd (path to project root folder) && ^ react-native run-android 

commands: 1.cd (path to the project folder / android) 2.gradlew clean 3. cd .. 4.react-native run-android

+16
source

I also had this problem. For me on Windows it was opening a command prompt as administrator. The problem is that the script does not have permission to delete the folder.

  1. Press the Windows key
  2. Type Command Prompt
  3. Right-click the command line result that appears
  4. .Click "Run as administrator"
  5. Click β€œYes” to open the β€œDo you want this application to be able to make changes to this device?” Pop-up.
  6. At the cd command prompt in your project directory
  7. run react-native run-android
+2
source

For me, the solution to the problem is to use the "watchman" as a file observer, as shown here: https://github.com/facebook/react-native/issues/9136#issuecomment-306486102

0
source

For a clean Android project, run the following command

 cd android &&./gradlew clean 

to restart

 cd .. && react-native run-android 
0
source

Source: https://habr.com/ru/post/1015425/


All Articles