Sign in Go Pro


Setting up Retrofit 2 and Issuing a HTTP GET Request

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next


In this Lesson you will learn:

  • How to set up Retrofit 2
  • Create a standalone Retrofit instance
  • Send a simple GET request
  • Enqueue a request for asynchronous communication

- Retrofit Documentation


I am getting an Error while Setting up Retrofit:
Failed to resolve: com.squareup.retrofit2:convertor-gson:2.4.0

I have just added these 2 dependencies

// REST Interface
implementation 'com.squareup.retrofit2:retrofit:2.4.0'

//JSON Parsing
implementation 'com.squareup.retrofit2:convertor-gson:2.4.0'

plz help......

There's a typo: should be converter, not convertor.


Hello Annyce.

I am trying to run the sample code, but it is not working. Could you give me a hand here, please?

There is an error appearing in the "Build" tab: Manifest merger failed with multiple errors, see logs.

Here is the content of my app/build.gradle:

apply plugin: ''

android {
compileSdkVersion 28

defaultConfig {
applicationId "info.adavis.adeptandroid"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
lintOptions {
abortOnError false
compileOptions {
sourceCompatibility JavaVersion.VERSION18
targetCompatibility JavaVersion.VERSION18

ext {
supportLibraryVersion = '28.0.0'
retrofitVersion = '2.5.0'

dependencies {
// Support Libraries
// implementation "$supportLibraryVersion"
implementation "androidx.appcompat:appcompat:1.0.0"
implementation "$supportLibraryVersion"
implementation "$supportLibraryVersion"

// REST Interactions
implementation ("com.squareup.retrofit2:retrofit:$retrofitVersion")

// JSON Parsing
implementation ''
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"

// View Injection
// implementation 'com.jakewharton:butterknife:7.0.1'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

// Logging
implementation 'com.jakewharton.timber:timber:3.1.0'

// Events
implementation 'de.greenrobot:eventbus:2.4.0'

// Image Loading
implementation 'com.squareup.picasso:picasso:2.5.2'

// Testing
testImplementation 'junit:junit:4.12'

PS: I don't know why the Markdown with ``` it is not working. Anyway...

Continuing, here is the content of my build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
dependencies {
classpath ''

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

allprojects {
repositories {

task clean(type: Delete) {
delete rootProject.buildDir

Another file I updated is the

Sun Apr 17 17:50:31 EDT 2016


Hi Rodrigo,

I've updated the branch with a few of the latest dependencies and I was able to build the app. Please try pulling the retrofit2 branch again => You may need to clean the project and/or invalidate caches and restart in Android Studio. I hope that helps!

Unfortunately I still can't run this project. See:

I tried today again, with no success.
Unfortunately, I am stucked.

Hello there, I just cloned the attached project for this course and migrated it to Androidx, when I build it shows build successful, however when I try to run the app on the emulator, I get the following:

<< The given artifact contains a string literal with a package reference '' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx. >>

Can anyone help me out ?

you'll have to update layout files and actual code to use AndroidX


Lessons in RetroFit2