Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的模拟器没有';不能使用NativeScript吗?_Android_Angular_Android Emulator_Nativescript_Json Server - Fatal编程技术网

Android 为什么我的模拟器没有';不能使用NativeScript吗?

Android 为什么我的模拟器没有';不能使用NativeScript吗?,android,angular,android-emulator,nativescript,json-server,Android,Angular,Android Emulator,Nativescript,Json Server,我已经在这里上传了我的项目,但当我尝试使用tns run android--device Pixel_2_API_29运行它时,它会打开我的模拟器,但会在屏幕上显示以下错误消息: 错误:0-未知错误Http失败响应https://10.0.2.2 我也尝试了以下几行,但都给出了相同的错误: export const baseURL = "http://10.0.2.2:3000/"; export const baseURL = "http://192.168.1.5:3000/"; expor

我已经在这里上传了我的项目,但当我尝试使用
tns run android--device Pixel_2_API_29
运行它时,它会打开我的模拟器,但会在屏幕上显示以下错误消息:

错误:0-未知错误Http失败响应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/";

为什么会发生这种情况?我如何修复它?

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

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

在这里设置:
your application/app/app\u 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">  

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

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

在这里设置:
your application/app/app\u 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">  


localhost
将无法确保工作,因为Emulator运行在自己的上下文中,更像是一个单独的设备<代码>http://10.0.2.2:3000-这是一个公共IP,首先确保它可以在浏览器/rest客户端中访问,它看起来不像是从我这边来的。@Manoj:它给了我
这个网站无法访问10.0.2.2需要很长时间才能响应。
@Manoj:我从这里找到的。我可以知道你到底想在这里做什么吗,你为什么要打那个IP?如果您试图访问本地计算机或公共服务器上托管的任何REST API,它应该是该计算机的IP。@Manoj:我有一个json服务器,当我运行它时,它会在
localhost:3000/
上监视。因此,我想让emulator查看该地址,并显示其中的内容。
localhost
无法确保emulator在自己的上下文中运行,更像是一个单独的设备<代码>http://10.0.2.2:3000-这是一个公共IP,首先确保它可以在浏览器/rest客户端中访问,它看起来不像是从我这边来的。@Manoj:它给了我
这个网站无法访问10.0.2.2需要很长时间才能响应。
@Manoj:我从这里找到的。我可以知道你到底想在这里做什么吗,你为什么要打那个IP?如果您试图访问本地计算机或公共服务器上托管的任何REST API,它应该是该计算机的IP。@Manoj:我有一个json服务器,当我运行它时,它会在
localhost:3000/
上监视。所以我想让模拟器观看这个地址,并显示其中的内容。