Unable to load script. Make sure

2020-06-11  本文已影响0人  学生黄哲

Unable to load script. Make sure you'reeither running a Metro server(run react-native start )or that your bundle ‘index. android.bundle’ is packaged correctly for release

从git上clone下来的项目

在Android 环境配置完成,并且外接手机设备没有问题。
运行npm run android 出现上面异常

查看项目目录下->android->app->src是否有debug文件夹
如没有 新建debug文件夹->新建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>

注:这个问题是因为Android9.0以上禁止了所有http请求,为了安全。所以手机设备和node服务不能通讯,我们配置src的debug的AndroidManifest.xml 文件 允许在debug模式下进行明文通讯(android:usesCleartextTraffic="true")

上一篇 下一篇

猜你喜欢

热点阅读