无法从Windows上的资产index.android.bundle加载脚本 [英] Unable to load script from assets index.android.bundle on windows
问题描述
我正在尝试在我的设备(Android 4.2.2)上首次运行我的第一个React Native项目.
I'm trying to run my first React Native project for first time on my device (Android 4.2.2).
然后我得到:
无法从资产index.android.bundle加载脚本
unable to load script from assets index.android.bundle
我使用的命令:
-
cd (project directory)
-
react-native start
-
react-native run-android
cd (project directory)
react-native start
react-native run-android
推荐答案
我花了数小时试图弄清楚这个问题.我的问题并不特定于Windows,而是特定于Android.
I spent hours trying to figure this issue out. My problem was not specific to Windows but is specific to Android.
访问开发服务器可以在本地和仿真器的浏览器中进行.唯一不起作用的是访问应用程序中的开发服务器.
Accessing the development server worked locally and in the emulator's browser. The only thing that did not work was accessing the development server in the app.
从Android 9.0(API级别28)开始,默认情况下禁用明文支持.
Starting with Android 9.0 (API level 28), cleartext support is disabled by default.
AndroidManifest.xml
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />
<application
...
android:usesCleartextTraffic="true"
...>
...
</application>
</manifest>
有关更多信息,请参见: https://stackoverflow.com/a/50834600/1713216
See for more info: https://stackoverflow.com/a/50834600/1713216
这篇关于无法从Windows上的资产index.android.bundle加载脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!