GsonConverter is not resolved



我在build.gradle文件中添加了这个。

build.gradle

  compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
  compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4

但GsonConverter的改造2仍然没有解决。

为什么不使用稳定版本?

compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0'

您还必须在渐变依赖项中添加gson

compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.0' 
compile 'com.google.code.gson:gson:2.6.2' // this should also be there

并创建这样的改造实例:

public static final String BASE_URL = "http://api.example.com/";
Retrofit retrofit = new Retrofit.Builder()
    .baseUrl(BASE_URL)
    .addConverterFactory(GsonConverterFactory.create())
    .build();

嘿,即使我也面临同样的问题,添加下面的行也不起作用。

compile 'com.squareup.retrofit2:converter-gson:2.0.0'

然后我去了maven存储库,下载了jar并粘贴在android工作室的libs文件夹中。链接如下:

[https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22converter-gson%22][1]

然后将以下行添加到渐变

compile files('libs/converter-gson-2.0.1.jar')
    compile 'com.google.code.gson:gson:2.6.2'

相关内容

最新更新