Biiiiiird
Biiiiiird

Reputation: 394

react-native run-android builds an old version of the code onto device

This occurs in both production and dev builds. I can connect to the dev server, reload, and the new code is built and runs on the device.

Step-by-step of what I have tried:

  1. Modify code.

  2. Re-bundle:

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

  1. ./gradlew clean

  2. react-native run-android - Builds old version

  3. react-native run-android --variant=release - Builds old version

Is there any way to completely wipe the android build and build from scratch? My gut tells me that run-android is not performing a full clean build.

Upvotes: 21

Views: 13734

Answers (2)

leonardomdr
leonardomdr

Reputation: 159

Maybe that's not exactly what you have faced. But I was creating a staging buildType in my react native project too, the build was fine (after dealing with some problems), but for some reason it was loading an old version of the app too.

After changing the buildType from staging to releaseStaging, it started to build as expected.

I hope this answer helps anyone that might land in this page just like I did.

I've answered in another topic too with more specific instructions.

Upvotes: 0

Gamma Ko
Gamma Ko

Reputation: 462

  1. Delete files inside directory android/app/src/main/assets.
  2. run $ 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
  3. $ react-native run-android

Upvotes: 44

Related Questions