Failed to resolve: com.squareup.retrofit2:retrofit:2.3.0

2017-06-29 android retrofit2

I tried to include retrofit library in android studio 2.2.3. I added the following line in gradle

compile 'com.squareup.retrofit2:retrofit:2.3.0'

But it is giving me the following error :

Failed to resolve: com.squareup.retrofit2:retrofit:2.3.0

What is the solution?

Answers

Failed to resolve: com.squareup.retrofit2:retrofit:2.3.0.

Retrofit requires at minimum Java 7 or Android 2.3.

You are not using android studio Version 2.3 . Upgrade your Studio version .

How to check Version .

 File > Settings-> Appearance & Behaviour -> System Settings -> Updates

put compile 'com.squareup.retrofit2:retrofit:2.3.0' in build.gradle(Module:app) and sync the project.It should work fine without any errors

The case also can be proxy too.
Disable proxy from Settings > Appearance and behaviour > System Settings > Http proxy
by checking No Proxy and also clear proxy lines from gradle.properties (Global properties) if you have one.

Check if you are not running an OFFLINE WORK, in settings> Build, Execution, Deployment > Gradle at the bottom, Offline work should not be checked.

I needed to declare google() in both buildscripts and allobjects

    buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0-alpha06'

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

allprojects {
    repositories {
        jcenter()
        google()
    }
}

Change your version to a newer version

implementation 'com.squareup.retrofit2:retrofit:2.4.0'

Related