我正在尝试将改版2.0.0-beta集成到我的应用中。
{
"success":true,
"categoryDetails":[
{
"topicId":550,
"categoryName":"Classshshs",
“categoryImageUrl” : “http://s3-apdd-southeast-1.amazonaws.com/tv-dev/member/photo/883191-medium130.jpg”,
},
{
"topicId":550661,
"categoryName":"Cricket sss",
“categoryImageUrl” : “http://s3-apdd-southeast-1.amazonaws.com/tv-dev/member/photo/883191-medium130.jpg”,
}
],
"totalCategoryCount":2
}
我的休息适配器
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://s3-ap-southeast-1.amazonaws.com").
addConverterFactory(GsonConverterFactory.create())
.build();
service=retrofit.create(RetrofitService.class);
我的通话方法
Call<Object> call=service.listRs();
call.enqueue(new Callback<Object>() {
@Override
public void onResponse(Response<Object> response) {
Log.e(TAG,"sucess"+response.toString());
}
@Override
public void onFailure(Throwable t) {
}
});
Caused by: java.lang.IllegalArgumentException: Unable to create call adapter for interface retrofit.Call
for method RetrofitService.listRs
at retrofit.Utils.methodError(Utils.java:201)
at retrofit.MethodHandler.createCallAdapter(MethodHandler.java:51)
at retrofit.MethodHandler.create(MethodHandler.java:29)
at retrofit.Retrofit.loadMethodHandler(Retrofit.java:138)
at retrofit.Retrofit$1.invoke(Retrofit.java:127)
at java.lang.reflect.Proxy.invoke(Proxy.java:397)
at $Proxy1.listRs(Unknown Source)
答案 0 :(得分:0)
在gradle中尝试这个
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.8.1'
答案 1 :(得分:-1)
尝试使用回调执行程序,如下所示:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://s3-ap-southeast-1.amazonaws.com").
addConverterFactory(GsonConverterFactory.create())
.callbackExecutor(Executors.newFixedThreadPool(1))
.build();