为什么我的模拟器不能与NativeScript一起使用?

时间:2019-06-29 06:46:19

标签: android angular android-emulator nativescript json-server

我已经在https://github.com/rezaee/conFusion上上传了我的项目,但是当我尝试使用tns run android --device Pixel_2_API_29运行它时,它会打开我的模拟器,但会在屏幕上显示此错误消息:

Error:0-Unknown Error Http failure response for https://10.0.2.2

我也尝试了以下几行,但都给出了相同的错误:

export const baseURL = "http://10.0.2.2:3000/";
export const baseURL = "http://192.168.1.5:3000/";
export const baseURL = "http://localhost:3000/";

为什么会发生这种情况,我该如何解决?

1 个答案:

答案 0 :(得分:1)

一个月的尝试之后,我在NativeScript的github上找到了以下答案:

在API29上进行测试,问题在于您可能缺少cleartext文件中的AndroidManifest.xml权限。

在此处设置:your-application/app/App_Resources/Android/src/main/AndroidManifest.xml

在AndroidManifest.xml中设置android:usesCleartextTraffic

<application android:name="com.tns.NativeScriptApplication"
          android:allowBackup="true"
          android:icon="@drawable/opportuity"
          android:label="@string/app_name"
          android:theme="@style/AppTheme"
          android:usesCleartextTraffic="true">