我試圖使用Retrofit 2.0的發佈版本和他們的Retrofit configuration上建議的GsonConverterFactory。Retrofit 2.0 non-beta,使用GsonConverterFactory
的問題是,GsonConverterFactory似乎只適用於改造1,和我現在我改造2,即使GsonConverterFactory上的2
這裏的β是我的搖籃依賴關係:
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
我找不到一個非beta版本的converter-gson,只是刪除-beta2
並沒有辦法。
運行此代碼:
import retrofit.GsonConverterFactory;
import retrofit2.Retrofit;
public class Service {
public void getListings()
{
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://www.google.com")
.addConverterFactory(GsonConverterFactory.create())
.build();
Services services = retrofit.create(Services.class);
}
}
我得到這個錯誤:
addConverterFactory (retrofit2.Converter.Factory) in Builder cannot be applied to (gson.GsonConverterFactory)
任何建議,除了運行改造2測試版?
謝謝!
對不起。我嘗試過,但沒有奏效。 – TooManyEduardos
最後需要2.0.0,它的工作原理!謝謝。可能編輯答案,以便我可以將其標記爲正確的答案。 – TooManyEduardos