错误:无法解析':app @ debug / compileClasspath'的依赖项:无法下载okhttp.jar(com.squareup.okhttp3:okhttp:4.3.1)

时间:2020-01-18 06:11:11

标签: android maven gradle

新建项目后,我在尝试在app/build.gradle中添加gradle时遇到了我无法处理的错误

请帮助我!

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation("com.squareup.okhttp3:okhttp:4.3.1") //that's the thing I want
}

错误

在57秒钟内配置成功错误:无法解析以下项的依赖关系 ':app @ debug / compileClasspath':无法下载okhttp.jar (com.squareup.okhttp3:okhttp:4.3.1)显示详细信息受影响的模块:应用程序

错误:无法解决':app @ debug / compileClasspath'的依赖关系: 无法下载okio.jar(com.squareup.okio:okio:2.4.1)显示 受影响的模块的详细信息:应用程序

1 个答案:

答案 0 :(得分:1)

来自this answer:您可以这样添加它

implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.8.0'

并要从maven获取依赖项,您需要将此添加到存储库中

repositories {
    mavenCentral()
}