无法解析 org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10

Posted

技术标签:

【中文标题】无法解析 org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10【英文标题】:Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10 【发布时间】:2021-01-24 10:08:37 【问题描述】:

我是 android 编程新手,但对 Flutter 并不陌生。到目前为止,我一直在 ios 上进行测试。现在,当我想在 Android 上进行测试时,我遇到了这个问题:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10.
     Required by:
         project :
      > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.4.10/kotlin-gradle-plugin-1.4.10.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.4.10/kotlin-gradle-plugin-1.4.10.pom'.
               > Connect to 127.0.0.1:1088 [/127.0.0.1] failed: Connection refused (Connection refused)
      > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10.
         > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.4.10/kotlin-gradle-plugin-1.4.10.pom'.
            > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.4.10/kotlin-gradle-plugin-1.4.10.pom'.
               > Connect to 127.0.0.1:1088 [/127.0.0.1] failed: Connection refused (Connection refused)
   > Could not resolve com.google.gms:google-services:4.3.3.
     Required by:
         project :
      > Could not resolve com.google.gms:google-services:4.3.3.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'.
               > Connect to 127.0.0.1:1088 [/127.0.0.1] failed: Connection refused (Connection refused)
      > Could not resolve com.google.gms:google-services:4.3.3.
         > Could not get resource 'https://jcenter.bintray.com/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/google/gms/google-services/4.3.3/google-services-4.3.3.pom'.
               > Connect to 127.0.0.1:1088 [/127.0.0.1] failed: Connection refused (Connection refused)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
Exception: Gradle task assembleDebug failed with exit code 1

这是我的android/build.gradle

buildscript 
    ext.kotlin_version = '1.4.10'
    repositories 
        google()  // Google's Maven repository
        jcenter()
    

    dependencies 
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    


allprojects 
    repositories 
        google()  // Google's Maven repository
        jcenter()
    


rootProject.buildDir = '../build'
subprojects 
    project.buildDir = "$rootProject.buildDir/$project.name"

subprojects 
    project.evaluationDependsOn(':app')


task clean(type: Delete) 
    delete rootProject.buildDir

由于我对 android 及其问题不是很熟悉,如果我需要在此问题中包含任何其他内容,请告诉我。

谢谢

【问题讨论】:

【参考方案1】:

脚本中的所有依赖请求最终都会出现相同的错误

连接到 127.0.0.1:1088 [/127.0.0.1] 失败:连接被拒绝(连接被拒绝)

可能是您已将系统配置为使用本地代理服务器,但实际上并未在该 1088 端口上运行。

【讨论】:

你能详细说明一下吗,或者告诉如何解决它?【参考方案2】:

由于 Jcenter() 现在在 2021 年被弃用, 您可以在 Project Level Gradle 中添加 mavencentral 为

repositories 
        google()
        mavenCentral()
    

【讨论】:

jcenter 已被弃用,但根据JFrog's announcement ConanCenter 和 JCenter 将暂时可用。

以上是关于无法解析 org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10的主要内容,如果未能解决你的问题,请参考以下文章

无法解析 org.jetbrains:kotlin-css-jvm:1.0.0-pre.31-kotlin-1.2.41

Kotlin gradle 无法初始化类 org.jetbrains.kotlin.gradle.internal.KotlinSourceSetProviderImplKt

无法修复:找不到 kotlin-reflect-1.3.72.jar (org.jetbrains.kotlin:kotlin-reflect:1.3.72)

libGDX与Kotlin错误“org.jetbrains.kotlin.kapt.idea.KaptModelBuilderService”

执行 org.jetbrains.kotlin 时缺少必需的类

“kotlin-android”和“org.jetbrains.kotlin.android”是一样的吗?