错误:不兼容的类型:GsonConverterFactory不能转换到厂
我试图用改造2.0.0.beta2,像下面错误:不兼容的类型:GsonConverterFactory不能转换到厂
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
为 GSON设立转换器的gradle这个错误抛出后
时GsonConverterFactory cannot be converted to Factory
如何解决?
我有问题......
I was using compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1' instead of 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.google.code.gson:gson:2.3'}
你可能的GsonConverterFactory
与Retrofit
第二测试版的第一个测试版。请确保您有
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
在gradle这个
Blackbelt;你需要时总是出现;感谢从房间-15 – Eenvincible
我得到一个错误:在生成器中的addConverterFactory(retrofit2.Converter.Factory)不能应用于(retrofit.GsonConverterFactory)' –
它取决于您正在使用的改造版本。这个答案指的是retrofi2的第二个测试版。 – Blackbelt
发表您的gradle这个 – Blackbelt
,我希望你不会添加GSON转换器gradle这个 –
请参阅此链接可能对你有帮助http://stackoverflow.com/questions/32343183/retrofit-could-not-locate-converter-for-class-crashing-app/32652747#32652747 –