改造生成器:
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl("recrutement.stb.com.tn:1010/PlateformeApi_Externe/api/Authorize/")
.addConverterFactory(GsonConverterFactory.create());
Retrofit retrofit=builder.build();
UserClient userClient=retrofit.create(UserClient.class);
问题:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.saiid.authetification/com.example.saiid.authetification.MainActivity}: java.lang.IllegalArgumentException: Illegal URL: recrutement.stb.com.tn:1010/PlateformeApi_Externe/api/Authorize/
答案 0 :(得分:0)
试试这个..http://
Retrofit.Builder builder = new Retrofit.Builder().baseUrl("http://recrutement.stb.com.tn:1010/PlateformeApi_Externe/api/Authorize/").addConverterFactory(GsonConverterFactory.create());
Retrofit retrofit = builder.build();
UserClient userClient = retrofit.create(UserClient.class);
答案 1 :(得分:0)
基本网址应该是这样的:
public final String BASE_URL = "http://18.156.18.81:8080";
所以它将从http://或https://开始使用:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
答案 2 :(得分:-1)
您的基本网址中缺少协议。您的基本网址必须以http://
或https://
开头。