React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:

无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。

我做错了什么?


当前回答

这也可能是由于在清单中禁用INTERNET权限造成的。我有一个不需要/使用任何互联网的应用程序,我已经删除了它。自从我更新这个应用程序已经有一段时间了,我已经完全忘记了它。花了大约一个小时把每个答案都试了一遍。

其他回答

请检查地铁服务器是否正在运行任何其他端口。如果有,停止所有服务器,然后重新启动服务器,再试一次。

如果你在linux上,从App根目录打开终端并运行

npm start

然后打开另一个终端窗口并运行:

react-native run-android

关闭代理,如果你在android studio设置代理,默认使用代理

    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

这个错误突然出现在我面前,而我解决它的方法是:

Android Studio中的AVD管理器 在虚拟设备的操作下按下箭头 擦除数据 重新启动地铁