0
當我調用我的inteface getRepo的方法它顯示一個錯誤服務方法無法返回void方法Github.getRepo當我運行並檢查調試它崩潰在interfac調用我讓我該getRepo方法無法使用retofit 2.0 Beta在android
my mainActivity mtehod to call the api is
Github api = GitHubService.getService();
api.getRepo("basil2style", new Callback<Repository>() {
@Override
public void onResponse(Call<Repository> call, Response<Repository> response) {
}
@Override
public void onFailure(Call<Repository> call, Throwable t) {
}
});
And my model class is
package functionapps.retrofitdemo.AsyncHelper;
public class Repository {
public String name;
public Repository(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
this is my interface and its calling class
public interface Github {
@GET("https://stackoverflow.com/users/{user}")
public void getRepo(@Path("user") String user, Callback<Repository> response);
}
public class GitHubService {
private static String API_URL = "https://api.github.com";
public static Github getService() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(API_URL)
.build();
Github github = retrofit.create(Github.class);
return github;
}
請分享堆棧跟蹤和分享改裝的版本,以及...像β2或3 .... –
com.squareup.retrofit2:改造:2.0.0-BETA4 –
請分享堆棧跟蹤.. –