React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
当前回答
在数小时寻找答案之后。解决方案是将节点降级到版本12.4。
在我的例子中,我意识到这个错误只发生在节点版本12.6的react native 0.60版本中。
其他回答
对我来说,这个错误是由react-native的升级引起的
从Android 9.0 (API级别28)开始,默认情况下禁用明文支持。
如果您检查了升级差异,您需要创建一个调试清单 android / app / src /调试/ AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
查看更多信息:https://stackoverflow.com/a/50834600/1713216
https://react-native-community.github.io/upgrade-helper/
这也可能是由于在清单中禁用INTERNET权限造成的。我有一个不需要/使用任何互联网的应用程序,我已经删除了它。自从我更新这个应用程序已经有一段时间了,我已经完全忘记了它。花了大约一个小时把每个答案都试了一遍。
首先执行步骤4和5,然后可以运行项目。如果您没有得到结果(步骤4和5),请执行以下步骤
1-尝试降级你的Node版本(当前版本是12.13.1)
choco uninstall nodejs
choco install nodejs --version 12.8
2-添加npm模块的路径(C:\Users\your user name\AppData\Roaming\npm)到系统变量而不是用户变量
3-使用命令全局安装react native
npm install -g react-native-cli
4-进入项目目录的根目录,执行以下命令:
react-native start
5-打开项目根目录下的另一个终端,执行以下命令:
react-native run-android
编辑:
你在用Genymotion ?是,执行以下步骤。
在以上步骤后,如果您得到以下错误?
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
打开你的genymotion,转到:
genymotion菜单->设置-> ADB ->然后选择使用自定义android sdk工具(点击浏览找到sdk位置)
最后,再次运行您的项目。
this works for me on ubuntu
1. if you are having node version 17 first downgrade its version:-
You can use n for node's version management.
this is very easy to use.
$ npm install -g n
then you can show your node version:
$ node -v
v16.13.2
2. create an assets folder inside root of the project:-
project\android\app\src\main\assets
set folder name should be assets
3. now the final step implement the given code inside the project folder:-
$cd project
/project$ 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
4. after following all these step react-native was successfully running on my pc
以下是我在不改变构建的情况下解决这个问题的方法:
1-关闭虚拟设备
2-在物理设备上测试-(它工作)
3-创建新的虚拟设备API 30 Android 10+
4-在新创建的虚拟设备上再次尝试,所有工作都像一个魅力。