android - 无法解析 org.jetbrains.kotlin :kotlin-gradle-plugin:1. 4.10

标签 android flutter kotlin gradle

我是 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 及其问题不是很熟悉,请让我知道我是否需要在此问题中包含其他任何内容。
谢谢

最佳答案

由于 Jcenter() 现在在 2021 年被弃用,
您可以将项目级 Gradle 中的 mavencentral 添加为

repositories {
        google()
        mavenCentral()
    }

关于android - 无法解析 org.jetbrains.kotlin :kotlin-gradle-plugin:1. 4.10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64278139/

相关文章:

java - 启动接收器不工作

java - 即使应用程序被杀死,如何发送通知

java - 选择图像时 Intent 进入新页面

flutter - 在 android/app 文件夹下创建 build 文件夹?

flutter - 带有ListView的AppBar(Flutter)

css - flutter 相当于关闭 CSS 背景过滤器 : blur(20px) saturation(180%)

android - 当我们在android Studio中添加一个新的kotlin类/文件以及主要 Activity 时,我们将xml文件释放到kotlin类/文件中。但

android - 使用 retrolambda 和 Android 时出现 eclipse 错误

generics - kotlin 中的高阶(或递归?)泛型类型参数

kotlin - Activity中如何调用suspend函数?