Could not get BatchedBridge, make sure your bundle is packaged correctly

来源:互联网 发布:网上申报软件下载 编辑:程序博客网 时间:2024/06/05 14:54

这里写图片描述

第一步在Android的assets文件夹下创建一下两个文件

这里写图片描述

只要文件名是这两个就可以了

index.android.bundle 以.bundle 作为后缀名
index.android.map 以.map 作为后缀名

第二步在package.json文件中scripts对象中添加一行属性

这里写图片描述

代码如下:

"bundle-android": "react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --sourcemap-output android/app/src/main/assets/index.android.map --assets-dest android/app/src/main/res/"

然后cd 你创建的项目的根目录下执行下面代码

react-native start > /dev/null 2>&1 &  curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

接下来再试试run-android,有效果了吗

0 0
原创粉丝点击