2015-10-14 105 views
6

我試圖用改造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

如何解決?

+2

發表您的gradle這個 – Blackbelt

+1

,我希望你不會添加GSON轉換器gradle這個 –

+0

請參閱此鏈接可能對你有幫助http://stackoverflow.com/questions/32343183/retrofit-could-not-locate-converter-for-class-crashing-app/32652747#32652747 –

回答

2

我有問題......

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'} 
11

你可能的GsonConverterFactoryRetrofit第二測試版的第一個測試版。請確保您有

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

在gradle這個

+1

Blackbelt;你需要時總是出現;感謝從房間-15 – Eenvincible

+0

我得到一個錯誤:在生成器中的addConverterFactory(retrofit2.Converter.Factory)不能應用於(retrofit.GsonConverterFactory)' –

+0

它取決於您正在使用的改造版本。這個答案指的是retrofi2的第二個測試版。 – Blackbelt

相關問題