Loading Old Bundle in React native . While running on Physical device

浪尽此生 提交于 2019-12-11 07:37:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!