问题
While trying to run generated build apk or debugging on physical device , It is loading old bundle. and not reflecting any changes, it Happens only with physical device on same network.
Following tricks are not working for me. 1.
Run the command in a terminal: ps ax | grep react-native
Kill all processes and run bundle script again.
2.
rm -rf $TMPDIR/react-*
3.
--resetCache true
4.
--reset-cache
5.
Permanent delete node_modules
npm cache clean –force
npm install
npm start -- --reset-cache
回答1:
The Story Starts Here.
Was getting error while loading on physical device.
So, For fixing it. Had to follow the below lines in project root folder
mkdir android/app/src/main/assets
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
react-native run-android
From second time on wards ,need to execute following code for updating the bundle before loading into physical device
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
回答2:
Try this to clean your current build.cd android && ./gradlew clean
cd .. && react-native run-android
Also delete the current generated APK inside the outputs/apk folder inside android.
And if you are using windows, try running the terminal window as administrator.
回答3:
try this command
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
and after that run again following command
react-native run-android
回答4:
These are the correct steps that worked for me in order to manually build the bundle and install it on the device, been scratching my head for hours until I managed to find how to do this properly:
cd android
./gradlew clean
cd ../
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
./gradlew assembleRelease
./gradlew installRelease
来源:https://stackoverflow.com/questions/48503152/loading-old-bundle-in-react-native-while-running-on-physical-device