Android Studio 3.0 - 无法找到方法“com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List”

2024-03-31

尝试使用 Android Studio 3.0 Canary 1 启动新的 Kotlin 项目会显示此错误。完整轨迹:

错误:找不到方法 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List;'。 导致此意外错误的可能原因包括:

  • 格拉德尔的 依赖项缓存可能已损坏(这有时会在网络连接后发生) 连接超时。)重新下载依赖项 并同步项目(需要网络)
  • Gradle 的状态 构建进程(守护进程)可能已损坏。停止所有 Gradle 守护进程可能会 解决这个问题。停止 Gradle 构建 进程(需要重新启动)
  • 您的项目可能正在使用 第三方插件与其他插件不兼容 请求的项目或 Gradle 版本 项目。
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

我已经尝试了前两个选项,第三方插件保留为默认值。

gradle-wrapper.properties

#Thu May 18 08:36:52 BST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip

构建.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.2-3'
    repositories {
        maven { url 'https://maven.google.com' }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.google.com' }
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我自己没有触及任何这些值,它们保留为默认值。创建非Kotlin新项目不会有这个问题。


In my 构建.gradle改变

ext.kotlin_version = '1.1.2-3'

to

ext.kotlin_version = '1.1.2-4'

解决了这个问题。

你可以找到最新版本here https://plugins.gradle.org/plugin/org.jetbrains.kotlin.android.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android Studio 3.0 - 无法找到方法“com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List” 的相关文章

随机推荐