Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: always gradlew clean before run react-native-run-android

If don't run cd android && ./gradlew clean before react-native run-android this fails with some error like:

Failed to create folder: ...

or

Failed to delete folder: ...

so I must run more times again to solve it.

Help me solve it without gradlew clean, please.

Thanks so much.

like image 221
Truong Avatar asked Mar 03 '17 03:03

Truong


People also ask

How do I run gradlew clean react native?

To clean cache in react native, open terminal, go to your project android folder, and run gradlew clean command it will clear react native cache.

What does gradlew clean do?

it removes build folder, as well configure your modules and then build your project. i use it before release any new app on playstore.

What is difference between gradle and gradlew?

The difference lies in the fact that ./gradlew indicates you are using a gradle wrapper. The wrapper is generally part of a project and it facilitates installation of gradle.


2 Answers

For clean android project run following command

cd android &&./gradlew clean 

to re-run

cd .. && react-native run-android 
like image 56
Vijay Vavdiya Avatar answered Sep 21 '22 22:09

Vijay Vavdiya


I'm having a similar problem since upgrading to RN 43. I haven't found the solution yet but realised that a clean in necessary before a successful build will occur.

Best solution for me so far is a batch script to start the project which 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 project/android folder) 2.gradlew clean 3. cd .. 4.react-native run-android

like image 41
James Cullis Avatar answered Sep 19 '22 22:09

James Cullis