无法加载脚本.确保您正在运行 Metro 服务器(运行“react-native start")或您的包“index.android.bundle" [英] Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle'

查看:57
本文介绍了无法加载脚本.确保您正在运行 Metro 服务器(运行“react-native start")或您的包“index.android.bundle"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 android studio 中运行我的项目我得到了那个错误,我只是安装了所有东西,我一步一步地遵循了一切,我使用 genymotion 作为模拟器,并使用 react-native 从 root 开始,检查端口 8081,禁用即时运行,以下链接的所有内容

Running my project in android studio I get that error, I just installed everything and I followed everything step by step, I'm using genymotion as an emulator, and use react-native start from the root, check port 8081, disable instant run, everything which is the following link

无法加载脚本.请确保您正在运行 Metro 服务器或您的包index.android.bundle"已正确打包以供发布

推荐答案

首先确保你已经在根目录下使用这个命令启动了bundler:

First of all make sure you have started the bundler using this command in root directory:

npm start 

react-native start

如果不行在下面的目录下手动添加assets文件夹

If doesn't work add assets folder manually in the following directory

android/app/src/main/{assets}

之后将 index.android.js 重命名为 index.js 然后使用以下命令:

After that rename index.android.js to index.js then use the following command:

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

现在您可以创建您的apk:

react-native run-android

这篇关于无法加载脚本.确保您正在运行 Metro 服务器(运行“react-native start")或您的包“index.android.bundle"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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