Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rebuild the entire Android folder?

Tags:

react-native

I have messed the files up in the Android folder and would like to rebuild the Android project inside of the Android folder. How do I do this?

Is it safe to delete the Android folder and then run react-native run-android, will that make it again?

Everything I've coded was wrote in index.android.js.

like image 493
User Avatar asked Apr 04 '17 18:04

User


People also ask

What is react native linking?

react-native link is an automatic way for installing native dependencies. It is an alternative to manually linking the dependency in your project. It works for both Android and iOS.


2 Answers

EDIT: Original answer was written in 2017 (RN v.0.47?). React-native environment evolved and AFAIK this solution is no longer valid.

Probably safe to remove.


I had similar problem, and ./gradlew clean didn't work, but i found hacky solution from How can I regenerate ios folder in React Native project?

Delete android folder (probably ios too), and then hacky part ->:

react-native upgrade  

(it regenerates folders, but it shouldn't be used to upgrade RN..)

And then

react-native link react-native run-android 

It worked for me :)

EDIT : one observation -> react-native sometimes goes crazy and cannot run some commands. Launching a new terminal helps. Bizarre :)

like image 115
3176243 Avatar answered Sep 18 '22 09:09

3176243


The solution if ur version of react-native >= 0.61.0 :

  1. sudo rm -rf android/ ios/

  2. yarn add react-native-eject

  3. npx react-native eject

enjoy !

like image 20
Jeremy HOFFMANN Avatar answered Sep 21 '22 09:09

Jeremy HOFFMANN