1

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?

Vishal Vaishnav
  • 3,346
  • 3
  • 26
  • 57
Newaj
  • 3,992
  • 4
  • 32
  • 50

6 Answers6

1

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
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • Ok, I'll update it. I noticed the requirement of retrofit. But I thought they were talking about android version 2.3. – Newaj Jun 29 '17 at 06:07
  • Unfortunately getting this weird error while updating : "Failed to download patch file: Cannot download 'https://dl.google.com/android/studio/patches/AI-145.3537739-162.4069837-patch-unix.jar': Tag mismatch! , response: 200 OK" – Newaj Jun 29 '17 at 07:47
  • @N.K.T https://stackoverflow.com/questions/18980276/cant-update-android-studio-only-download – IntelliJ Amiya Jun 29 '17 at 07:48
  • I have "Update & Restart" button. But it's giving me the error. – Newaj Jun 29 '17 at 07:53
  • 1
    You are right. After updating studio, the error disappears! Thank you. – Newaj Jul 01 '17 at 02:30
  • @N.K.T Glad to hear .Happy coding – IntelliJ Amiya Jul 01 '17 at 05:24
1

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

Salman Zafar
  • 3,844
  • 5
  • 20
  • 43
0

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

Siva agarwal
  • 97
  • 1
  • 8
0

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.

Mahdi-Malv
  • 16,677
  • 10
  • 70
  • 117
0

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()
    }
}
fullmoon
  • 8,030
  • 5
  • 43
  • 58
0

Change your version to a newer version

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