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

标签 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
}

错误

CONFIGURE SUCCESSFUL in 57s ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:4.3.1) Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not download okio.jar (com.squareup.okio:okio:2.4.1) Show Details Affected Modules: app

最佳答案

this answer:您可以像这样添加它

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

并从maven获取依赖项,您需要将此添加到存储库中
repositories {
    mavenCentral()
}

关于android - 错误:无法解析 ':app@debug/compileClasspath'的依赖项:无法下载okhttp.jar(com.squareup.okhttp3:okhttp:4.3.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59798010/

相关文章:

java - 为什么文本没有被共享?请查看详情

android - 有没有办法在android studio中实时监控电池使用情况?

java - 是否存在通过 jar、manifest... 明确设置 --add-exports、--add-opens 指令的方法,以避免在命令行上传递它们?

Android Studio 始终排除构建/源文件夹

android - 未找到 ID 为 'com.android.model.native' 的插件

android - Ionic 在 iOS 版本 8 上出现闪屏后崩溃

java - 如何从 USB pendrive 获取文件?

java - tomcat在spring添加spring data redis依赖后不启动

java - 如何使运行 Arquillian 功能测试的 maven-failsafe-plugin 知道堆栈跟踪中的 EJB 行号

gradle - 在 gradle 构建过程中找不到插件错误