【发布时间】:2015-12-11 02:41:33
【问题描述】:
我正在关注this tutorial 并尝试了更多,但我总是收到错误:Cannot resolve symbol for RestAdapter。所以我用谷歌搜索了this SO question 并给出了答案,其中包含我已经在我的 gradle 依赖项中拥有的compile 'com.squareup.retrofit:retrofit:1.9.0':
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0' //As you can see here
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}
这是调用错误的类和方法:
public class ServiceGenerator {
public static final String API_BASE_URL = "http://your.api-base.url";
private static RestAdapter.Builder builder = new RestAdapter.Builder()
.setEndpoint(API_BASE_URL)
.setClient(new OkClient(new OkHttpClient()));
public static <S> S createService(Class<S> serviceClass) {
RestAdapter adapter = builder.build();
return adapter.create(serviceClass);
}
}
【问题讨论】:
标签: android retrofit android-library okhttp android-async-http