【发布时间】:2016-05-12 14:57:43
【问题描述】:
我正在尝试遵循 Retrofit2 Getting Started and Create an Android Client 的本教程。
进口很好
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
除了一件事,我可以很好地按照教程进行操作。我正在尝试创建GitHubService Interface,但遇到了两个问题:Call<V> 表示它不接受任何类型参数,而且我也不确定将Contributor 类放在哪里,因为它仅根据教程声明为static,这是否意味着它嵌套在某个地方?
import okhttp3.Call;
import retrofit2.http.GET;
import retrofit2.http.Path;
public interface GitHubClient {
@GET("/repos/{owner}/{repo}/contributors")
Call<List<Contributor>> contributors(
@Path("owner") String owner,
@Path("repo") String repo
);
}
static class Contributor {
String login;
int contributions;
}
我将 Contributor 类放在一个单独的文件中,并将其公开。 另外,Call 类不会在 Android Studio 中自动导入,我必须手动选择它,但它是我得到的唯一 Call(Android 手机 api 除外)
请帮助我了解为什么会出现此错误,据我所知,周围没有人有相同的东西,所以我错过了一些基本的东西。
【问题讨论】:
标签: java android android-studio retrofit2 okhttp3