错误:找不到 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31

ALX*_*dev 2 android gradle android-gradle-plugin

我想更新 Android Gradle 插件,但我收到此错误:

ERROR: Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31.
Run Code Online (Sandbox Code Playgroud)


这些是我添加的用于更新 Android Gradle 插件(build.gradle 文件)的行:

buildscript {
    repositories {
        // Gradle 4.1 and higher include support for Google's Maven repo using
        // the google() method. And you need to include this repo to download
        // Android Gradle plugin 3.0.0 or higher.
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
    }
}

Run Code Online (Sandbox Code Playgroud)

Ale*_*xTa 11

您缺少一些存储库(jcenter)和一些依赖项(kotlin-gradle-plugin)。这就是为什么找不到 Kotlin 的原因。

您的build.gradle(Project:android)文件应如下所示:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.4.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

  • 文件中的“task clean...”代码有什么作用?每个项目/应用程序都应该如此吗? (2认同)