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

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

Unable to resolve dependency for ':app@ReleasesDebug/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.8.1) Open File Show Details

 

原因是无法下载okhttp,

方法:

Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.8.1)_第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
}

你可能感兴趣的:(开发中遇到的错误及解决方法)