![](/img/trans.png)
[英]“jcenter.bintray.com:443 failed to respond” error in Android Studio
[英]FAILED TO CONNECT TO /127.0.0.1:443 - ANDROID STUDIO
当我尝试在 android 工作室中运行我的应用程序项目时,我遇到了这种问题,它一直给我一个错误“无法连接到 /127.0.0.1:443 ”。 我为此使用本地 ip。 但是当我尝试使用 192.168.1.10 或 10.0.2.2 时它也不起作用。
这是我的复古代码
public class RetroServer {
private static final String baseURL = "https://127.0.0.1/laundry/";
private static Retrofit retro;
public static Retrofit konekRetrofit(){
if(retro == null){
retro = new Retrofit.Builder()
.baseUrl(baseURL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retro;
}
在我的复古代码中有 2 个这样的符号}}
这是我的 androidmanifest.xml 代码
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Laundry">
<activity
android:name=".Activity.MainActivity"
android:exported="true"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
如果你们能帮我解决这个问题,非常感谢
如果你在 localhost 中运行,你应该使用http://10.0.2.2:8080/
作为基础 url,你需要指定端口,否则它将不起作用。
你能在你的模拟器中做简单的测试吗? 从你的模拟器。 能不能打开浏览器。 之后,打开您的 URL。 (10.0.2.2) 如果一切顺利。 然后您需要在 android 清单中设置 network_config。 请查看https://developer.android.com/training/articles/security-config
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
<base-config cleartextTrafficPermitted="false" />
</network-security-config>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.