【发布时间】:2019-11-10 22:15:41
【问题描述】:
我已经在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/";
为什么会发生这种情况,我该如何解决?
【问题讨论】:
-
localhost肯定不会工作,因为模拟器在它自己的上下文中运行,更像是一个单独的设备。http://10.0.2.2:3000- 它是公共 IP,首先确保它可以在浏览器/rest 客户端中访问,从我的角度来看,它看起来不像。 -
@Manoj:它给了我
This site can’t be reached 10.0.2.2 took too long to respond. -
@Manoj:我从这里找到它developer.android.com/studio/run/emulator-networking
-
我想知道你到底想在这里做什么,为什么你会点击那个IP?如果您尝试访问托管在本地机器或公共服务器上的任何 REST API,它应该是该机器的 IP。
-
@Manoj:我有一个 json 服务器,当我运行它时,它会在
localhost:3000/上监视。所以我喜欢让模拟器观察那个地址并显示那里的内容。
标签: android angular android-emulator nativescript json-server