实施 OKHTTP 不适用于 Android 项目

Implementation OKHTTP doesn't work on Android project

我遵循了这个教程:https://www.journaldev.com/13629/okhttp-android-example-tutorial 但是当我尝试启动项目时给我这个错误:

Execution failed for task ':app:checkDebugAarMetadata'.
 Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
    Could not find com.squareup.okhttp3:okhttps:3.4.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/squareup/okhttp3/okhttps/3.4.1/okhttps-3.4.1.pom
       - https://repo.maven.apache.org/maven2/com/squareup/okhttp3/okhttps/3.4.1/okhttps-3.4.1.pom
       - https://jcenter.bintray.com/com/squareup/okhttp3/okhttps/3.4.1/okhttps-3.4.1.pom
     Required by:
         project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

正是在我尝试编写 implementation 'com.squareup.okhttp3:okhttps:3.4.1'

的时候

在您的 build.gredle 文件中使用它

 dependencies {    
        //Retrofit
        implementation 'com.squareup.retrofit2:retrofit:2.9.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
        implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
        implementation 'com.squareup.okhttp3:okhttp:4.9.0'
        implementation 'com.squareup.okhttp3:okhttp-urlconnection:4.4.1'
    }

这可能对某人有帮助