【发布时间】:2022-01-05 08:46:37
【问题描述】:
当我尝试在 android studio 中运行我的应用项目时遇到这种问题,它一直给我一个错误“无法连接到 /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>
如果你们能帮我解决这个问题,非常感谢
【问题讨论】:
-
try to run my app project in android studio?你在做什么?我宁愿认为您会尝试在 Android 手机上运行您的 Android 应用程序。很不清楚。 -
我必须在 android studio 模拟器上运行该应用程序,因为这个应用程序用于我的期末考试,我必须稍后展示它
-
请删除
android-studio标签。并在您的帖子中说明您使用的是模拟器。
标签: java android android-studio localhost ip