React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
React-native run-android命令通过在android模拟器中留下消息来终止。信息如下:
无法加载脚本。确保你要么运行Metro服务器,要么运行你的捆绑包index.android。Bundle '被正确地打包以便发布。
我做错了什么?
当前回答
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
其他回答
如果你所有的配置都是正确的,那么试试这个:
adb reverse tcp:8081 tcp:8081
Why?
当RN打包程序正在运行时,在您的浏览器中有一个活动的web服务器,地址为127.0.0.1:8081。应用程序的JS包就是从这个服务器提供的,并在您进行更改时进行刷新。如果没有反向代理,您的手机将无法连接到该地址。
所有功劳归于Swingline0 .
你可以尝试以下方法:
在AndroidManifest.xml中添加这一行
<application
[...]
android:usesCleartextTraffic="true"
/>
[...]
</application>
编辑: 注意,为了应用程序的安全性,在生产环境中它必须为假
在尝试了几种方法后,这对我来说很有效。
在文件node_modules\metro-config\src\defaults\blacklist.js中
替换:
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
:
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
希望这能有所帮助。
这种错误的可能性也是错误的路径,检查一次
export ANDROID_HOME=/Users/microrentindia/Library/Android/sdk/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
试试这个命令
~/Library/Android/sdk/platform-tools/adb -s emulator-5554 reverse tcp:8081 tcp:8081