无法从 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(项目目录)
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
这篇关于无法从 windows 上的资产 index.android.bundle 加载脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!