React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
当前回答
我也遇到过这个问题。我解决了下面这一步。
在Environment Veritable中检查android sdk路径。
添加 系统变量中的ANDROID_HOME = C:\Users\user_name\AppData\Local\Android\Sdk 而且 C:\Users\user_name\AppData\Local\Android\Sdk\platform-tools路径在“系统变量”中
替换sharedBlacklist如下代码段
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
在node_modules / metro-config / src / / blacklist.js违约
然后执行npx react-native run-android——port 9001
编码. .快乐!
其他回答
我只是想补充一个这里没有提到的不明显的可能性。我正在使用@react-native-community/netinfo来检测网络变化,主要是网络状态。为了测试网络关闭状态,需要关闭模拟器上的WIFI开关。这也有效地切断了模拟器和调试环境之间的桥梁。测试结束后,我没有重新开启WIFI,因为我离开了电脑,回来后很快就忘了这事。
其他人也有可能是这种情况,在采取任何其他激烈步骤之前,值得检查一下。
请检查地铁服务器是否正在运行任何其他端口。如果有,停止所有服务器,然后重新启动服务器,再试一次。
对我来说,这个错误是由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/
我做了: react-native开始 而且 NPX react-native run-android。
然而,对于Min19,(基于Ubuntu的)我也有同样的问题,直到我运行:
echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
来自: https://reactnative.dev/docs/troubleshooting#content
至少我手机里还有软件在运行。
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