在 React Native 中加载旧包.在物理设备上运行时 [英] Loading Old Bundle in React native . While running on Physical device

查看:35
本文介绍了在 React Native 中加载旧包.在物理设备上运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在物理设备上运行生成的构建 apk 或调试时,它正在加载旧包.并且不反映任何变化,它只发生在同一网络上的物理设备上.

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.

以下技巧对我不起作用.1.

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

推荐答案

故事从这里开始.

在物理设备上加载时出错.

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

这篇关于在 React Native 中加载旧包.在物理设备上运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆