Search code examples
androidretrofit2

Retrofit convertor-gson not being recognized


So I'm trying to create an android (Kotlin + Compose) app that makes some API requests. For that, I'm using the following packages/dependenices:

implementation("com.squareup.retrofit2:retrofit:2.9.0") // network calls
implementation("com.squareaup.retrofit2:convertor-gson:2.9.0") // json to object

I've synced the project already, but I can't import the convertor-gson in my project. Specifically, I'm trying to use GsonConverterFactory, but can't use it because it is not recognized.

This is how the import looks like:

retrofit2 imports

Am I doing something wrong?


Solution

  • Your GSON dependency has a typo. It should be:

    implementation("com.squareup.retrofit2:converter-gson:2.11.0")
    

    Its squareup, not squareaup. And converter, not convertor.

    The imports should be:

    import retrofit2.Retrofit
    import retrofit2.converter.gson.GsonConverterFactory