1
// Retrofit
compile 'com.squareup.retrofit2:retrofit:2.1.0'

// JSON Parsing
compile 'com.google.code.gson:gson:2.6.1'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

My question is regarding the second and third dependency added. I do understand it is related to JSON conversion. If the third dependency is added,would the second dependency still be needed?

I have seen them both being added on several examples. For e.g: https://www.androidhive.info/2016/05/android-working-with-retrofit-http-library/ https://code.tutsplus.com/tutorials/sending-data-with-retrofit-2-http-client-for-android--cms-27845

1 Answers1

2

At the source of Retrofit Gson contverter library, there is a dependency of Gson.

<dependency>
  <groupId>com.google.code.gson</groupId>
  <artifactId>gson</artifactId>
</dependency>

So, when you include com.squareup.retrofit2:converter-gson as your dependency, com.google.code.gson:gson will be automatically included.

So, you will not need to include the Gson dependency explicitly.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59