Anjana
Anjana

Reputation: 779

Reset android/ios project in react native

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?

Upvotes: 1

Views: 6772

Answers (3)

noone
noone

Reputation: 6568

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

Upvotes: 1

Gianfranco P
Gianfranco P

Reputation: 10794

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

Upvotes: 4

Oleksandr Cherniavenko
Oleksandr Cherniavenko

Reputation: 1575

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"

Upvotes: 1

Related Questions