React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
当前回答
我的解决方案如下:
启动Metro服务器
$ react-native start
开始安卓
$ react-native run-android
如果看到错误提示“端口8081已被使用”,那么您可以终止该进程并重新运行
$ react-native start
参见React Native故障诊断页面。
其他回答
试试这个命令
~/Library/Android/sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081
在某些情况下,您可能需要关闭React-native捆绑器的端口 用相同的进程重新运行应用程序
1.sudo kill -9 $(sudo lsof -t -i:9001)
2.npm start inside the project
3. react-native run-android
重要, 您的环境中可能有许多Virtual设备。如果您正在更改AVD,请确保再次重复设置。
调试信息,
如果您遇到上述错误,您必须首先验证端口8081上正在运行什么
最快的方法是在终端中使用以下命令
netstat -aon | findstr 8081
如果显示了什么,就意味着端口被阻塞了。如果可能的话,解除那个端口的封锁。
否则,您将需要更改端口。Naveen Kumar在上面的评论中已经提到了这个过程
react-native run-android --port=9001
确保9001也没有被使用:)
可能你的端口被占用了。 尝试在不同的端口上运行:
adb reverse tcp:6666 tcp:6666
react-native run-android --port 6666
检查您正在使用的端口是否空闲
linux:
lsof | grep LISTEN
窗口:
netstat -an
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