React native 在React native中加载旧捆绑包。在物理设备上运行时

React native 在React native中加载旧捆绑包。在物理设备上运行时,react-native,react-native-android,React Native,React Native Android,当尝试在物理设备上运行生成的构建apk或调试时,它正在加载旧包。而且不反映任何变化,它只发生在同一网络上的物理设备上 下面的技巧对我不起作用。 一, 二, 三, 四, 五, 尝试此操作以清除当前版本。 cd-android&./gradlew-clean cd.&&反应本机运行android 同时删除android中outputs/APK文件夹中当前生成的APK 如果您使用的是windows,请尝试以管理员身份运行终端窗口。故事从这里开始。 在物理设备上加载时出错 所以,为了修复它。 必须遵循

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

下面的技巧对我不起作用。 一,

二,

三,

四,

五,


尝试此操作以清除当前版本。
cd-android&./gradlew-clean

cd.&&反应本机运行android

同时删除android中outputs/APK文件夹中当前生成的APK

如果您使用的是windows,请尝试以管理员身份运行终端窗口。

故事从这里开始。

在物理设备上加载时出错

所以,为了修复它。 必须遵循项目根文件夹中的以下行

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
从第二次开始,在加载到物理设备之前,需要执行以下代码来更新捆绑包

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
试试这个命令

curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
然后,按照命令再次运行

react-native run-android

为了手动构建捆绑包并将其安装到设备上,这些步骤对我来说是正确的,我绞尽脑汁了好几个小时,直到找到正确的方法:

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

是的,我是windows用户。它不起作用了。仍然返回旧的包输出。不反映任何changesTry从emulator卸载应用程序,或在emulator上擦除数据并查看是否修复了此问题。我不知道发生了什么,只是一个建议。模拟器没有问题,它工作正常。问题是,当只在物理设备上运行时,我不知道发生了什么。你试过在另一台android设备上安装这个捆绑包吗?我修复了它并找到了解决方案!我知道这也是为android更新捆绑包的另一种方法。但是上面的命令将为我返回错误,因为我的条目文件是index.js而不是index.android.js。。
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
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
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
react-native run-android
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