我正在为我的Android应用程序使用retrofit 1.8将get请求发送到以下链接https://hamadataha-alfylovealfy.c9users.io/api/posts/1。这是我放置界面的类
package base;
import model.User;
import retrofit.Callback;
import retrofit.http.GET;
import retrofit.http.Path;
public class Interfaces {
public interface getUser {
@GET("/api/posts/2")
public void getUser(Callback<User> response);
}
}
这是RetrofitSingleton类 包基;
import retrofit.*;
public class RetrofitSingleton {
private static final String BASE_URL = "https://hamadataha-alfylovealfy.c9users.io";
private static RestAdapter restAdapter = null;
public static RestAdapter getInstance(){
if (restAdapter == null){
restAdapter = new RestAdapter.Builder()
.setEndpoint(BASE_URL)
.build();
}
return restAdapter;
}
}
在我的活动中,我这样称呼请求
public void ApiTest(){
Interfaces.getUser call = RetrofitSingleton.getInstance().create(Interfaces.getUser.class);
call.getUser( new Callback<User>() {
@Override
public void success(User user, Response response) {
setCurrentUser(new User("yessss", "yessss", "yessss"));
}
@Override
public void failure(RetrofitError error) {
setCurrentUser(new User("no,", "no", "no"));
Log.d("hello", error.toString());
}
});
}
但是,它始终以logcat
中的以下内容结束retrofit.RetrofitError: No static field METHODS of type Ljava/util/Set; in class Lcom/squareup/okhttp/internal/http/HttpMethod; or its superclasses (declaration of 'com.squareup.okhttp.internal.http.HttpMethod' appears in /data/app/com.karim.m3-2/base.apk)
知道这个错误可能是什么?