Android 改型2:没有虚拟方法newJsonReader(Ljava/io/Reader;)NoSuchMethodException

Android 改型2:没有虚拟方法newJsonReader(Ljava/io/Reader;)NoSuchMethodException,android,gson,retrofit,retrofit2,Android,Gson,Retrofit,Retrofit2,我正在整个互联网上搜索这个错误,但是,只有一个stackoverflow条目没有答案或注释。 我正在尝试使用改装2。这是我第一次使用它。以下是我的依赖项: compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.google.code.gson:gson:2.6.2' 我排除了任何OkHttp库,因为改型已经使用了它 这是

我正在整个互联网上搜索这个错误,但是,只有一个stackoverflow条目没有答案或注释。 我正在尝试使用改装2。这是我第一次使用它。以下是我的依赖项:

compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.google.code.gson:gson:2.6.2'
我排除了任何OkHttp库,因为改型已经使用了它

这是我的请求界面:

public interface LoginService {
    @POST(HTTPService.AUTHENTICATIO_URL)
    Call<User> login();
}

谢谢您的帮助。

我开始使用较新的版本:

compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'

错误消失了。

我看到了一些关于这方面的问题。该错误意味着该代码正与较旧版本的Gson链接。我觉得你的依赖关系很好。您以前是否使用过较旧版本的Gson?你试过清理你的项目和重建吗?@iagreen,哈哈,我就是这么想的:D,你就是那个人!可悲的是,他没有帮助。
 @Override
public void loadData(DataSource.LoadJsonCallback loadJsonCallback) {
    String login = mUser.getLogin();
    String password = mUser.getPassword();
    LoginService loginService =
            ServiceGenerator.createService(LoginService.class, login, password, "");
    Call<User> call = loginService.login();
    String a = call.request().url().toString();
    call.enqueue(new Callback<User>() {
        @Override
        public void onResponse(Call<User> call, Response<User> response) {
            try {
                loadJsonCallback.onTasksLoaded(response.body());
                User a = response.body();
                mUser = getDataFromJson("");
                if (mUser != null) {
                    mUser.setPassword(password);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        @Override
        public void onFailure(Call<User> call, Throwable t) {
            loadJsonCallback.onDataNotAvailable(t.getMessage());
        }
    });

}
java.lang.NoSuchMethodError: No virtual method newJsonReader(Ljava/io/Reader;)Lcom/google/gson/stream/JsonReader; in class Lcom/google/gson/Gson; or its super classes (declaration of 'com.google.gson.Gson' appears in /data/app/org.ucomplex.ucomplex-2/base.apk)
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'