Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.3.1)

gradle添加     implementation 'com.squareup.okhttp3:okhttp:3.3.1'     是报错:

Unable to resolve dependency for ':[email protected]/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.3.1) Open File Show Details

 

原因是无法下载okhttp,

方法:

Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.3.1)

在项目的gradle里面添加如下:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
//        classpath 'com.android.tools.build:gradle:2.2.0-alpha1'
//        classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 
allprojects {
    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url 'https://maven.google.com' }
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots'
        }
        maven { url "https://jitpack.io" }
    }
}
 
task clean(type: Delete) {
    delete rootProject.buildDir
}