1

How can I reset Android/iOS project in React Native? Like in Ionic, we can use "ionic platform rm android" & then add it again, so it will add fresh project. How I can do same in React Native?

Anjana
  • 759
  • 2
  • 12
  • 33
  • These links might help you. For Android: https://stackoverflow.com/questions/43214862/how-to-rebuild-the-entire-android-folder For ios: https://stackoverflow.com/questions/42506068/how-can-i-regenerate-ios-folder-in-react-native-project – Chandan Kumar Jan 29 '18 at 12:51

3 Answers3

4

I had issues with Pod dependencies or Cocoapods in iOS. Removing and de-integrating CocoaPods from my project fixed it.

gem install cocoapods-deintegrate
cd ios
pod deintegrate
pod install

https://github.com/CocoaPods/cocoapods-deintegrate

Gianfranco P.
  • 10,049
  • 6
  • 51
  • 68
1

Just remove folder ios/build for ios, and android/build. For android you may also need cd ./android && ./gradlew clean in some cases.

If you can create command inside package.json like "clear-android": "rm -rf android/build", "clear-ios": "rm -rf ios/build"

1

To reset android build, delete cache and refresh you may need to do the following

If you have already generated signed keys and updated those in the gradles, you can build the production build, unless you can build the developer build (debugging apk)

  1. Delete build inside android/app folder
  2. Delete build inside android folder
  3. run rm -rf $HOME/.gradle/caches/ to delete cache
  4. Open build.gradle -> android/app/build.gradle
  5. comment out this line apply from: "../../node_modules/react-native/react.gradle"
  6. Delete index.android.bundle file from assets folder ( android/app/src/main/assets/index.android.bundle)
  7. run following command react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
  8. react-native run-android --variant=release (you have to generate signed keys and all the keys should updated in the gradle file ref (https://s-pace.github.io/react-native/docs/signed-apk-android.html)
  9. if you dont have generate signed keys still you can run react-native run-android
noone
  • 6,168
  • 2
  • 42
  • 51