Android studio 从android studio连接到本地主机

Android studio 从android studio连接到本地主机,android-studio,Android Studio,我正在尝试从在android studio下运行的应用程序进行连接 在应用程序中,我有一个基本url: 我连接到虚拟设备的浏览器中,找到了我想要的页面,因此我知道地址是正确的 我启动应用程序并进入登录页面 我键入变量并按“登录” 我在日志中看到: 2020-11-21 18:23:25.682 27502-27795/com.xxxxxx.user D/OkHttp: --> POST http://localhost/xxxxxx/public/api/user/oauth/token

我正在尝试从在android studio下运行的应用程序进行连接

在应用程序中,我有一个基本url:

我连接到虚拟设备的浏览器中,找到了我想要的页面,因此我知道地址是正确的

我启动应用程序并进入登录页面

我键入变量并按“登录”

我在日志中看到:

2020-11-21 18:23:25.682 27502-27795/com.xxxxxx.user D/OkHttp: --> POST http://localhost/xxxxxx/public/api/user/oauth/token
2020-11-21 18:23:25.682 27502-27795/com.xxxxxx.user D/OkHttp: Content-Type: application/x-www-form-urlencoded
2020-11-21 18:23:25.704 27502-27795/com.xxxxxx.user D/OkHttp: <-- HTTP FAILED: java.net.ConnectException: Failed to connect to localhost/xxxxxx:80
2020-11-21 18:23:25.682 27502-27795/com.xxxxxx.user D/OkHttp:-->POSThttp://localhost/xxxxxx/public/api/user/oauth/token
2020-11-21 18:23:25.682 27502-27795/com.xxxxxx.user D/OkHttp:Content Type:application/x-www-form-urlencoded

2020-11-21 18:23:25.704 27502-27795/com.xxxxxx.user D/OkHttp:因为本例中的localhost是电话,当你想连接到你的电脑时,在我的应用程序中使用192.168.10.224代替localhost,而不是localhost,但我仍然可以尝试在代码中找到发出请求的位置并找出url的来源?我找不到它:(任何有答案的人。
E/AAAA:  device token : 123456789
E/AAAA:  login: req: {"
password":"123456","
device_id":"123","
grant_type":"password","
device_token":"123456789","
device_type":"android","
client_secret":"111111111111","
client_id":"2","
username":"MYEMAIL"}
D/OkHttp: --> POST http://xxxxx/public/api/user/oauth/token
D/OkHttp: Content-Type: application/x-www-form-urlencoded
    Content-Length: 350
D/OkHttp: password=123456&device_id=123&grant_type=password&device_token=123456789&device_type=android&client_secret=111111111111&client_id=2&username=MYEMAIL
    --> END POST (350-byte body)
D/OkHttp: <-- 405 Method Not Allowed http://xxxxx/public/api/user/oauth/token (113ms)