retrofit convertor factory can not access GsonConverterFactory

前端 未结 5 1535
情话喂你
情话喂你 2020-12-08 18:38

I have included these dependencies to my project:

compile \'com.squareup.retrofit:retrofit:2.0.0-beta2\'
compile \'com.squareup.retrofit:convert

相关标签:
5条回答
  • 2020-12-08 18:44

    With latest Beta 2.0.3 release you need to add :

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

    Make sure to match the retrofit library version with gson converter version.

    0 讨论(0)
  • 2020-12-08 18:50

    Try to use same version for retrofit and converter-gson - 2.0.0-beta2. You are using beta2 for retrofit and beta1 for converter.

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

    Important note!

    Retrofit change its package name since 2.0.0-beta3 version. Now you should use com.squareup.retrofit2. Here is example:

    implementation 'com.squareup.retrofit2:retrofit:2.2.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
    
    0 讨论(0)
  • 2020-12-08 18:55
      error: method addConverterFactory in class Builder cannot be applied to given types;
        required: Factory
        found: GsonConverterFactory
        reason: actual argument GsonConverterFactory cannot be converted to Factory by method invocation conversion
    

    If you are getting this error, The reason is wrong dependancy included.

    Add/ change dependency in application build.gradle file as

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

    make sure that converter version is 2.0.0-beta2 not 2.0.0-beta1.

    0 讨论(0)
  • 2020-12-08 19:06

    In build.gradle (app) instead of:

    implementation 'com.google.code.gson:gson:2.8.2'
    

    write:

    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    
    0 讨论(0)
  • 2020-12-08 19:06

    This is the latest:

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

    If you use beta version:

    compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
    compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
    
    0 讨论(0)
提交回复
热议问题