android-studio - Android Studio 3.0 - 找不到方法 'com.a

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

Error:Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List;'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
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

build.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新项目没有这个问题。

最佳答案

在我的 build.gradle 变化中

ext.kotlin_version = '1.1.2-3'

ext.kotlin_version = '1.1.2-4'

解决了这个问题。

您可以找到最新版本 here .

关于android-studio - Android Studio 3.0 - 找不到方法 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44042754/

相关文章:

function - 何时在 Kotlin 中使用内联函数?

syntax - Kotlin 二级构造函数

generics - 如何在 Kotlin 中将 TypeToken + 泛型与 Gson 一起使用

kotlin - Kotlin中折叠和减少之间的区别,何时使用?

generics - Kotlin 中的 reified 关键字是如何工作的?

enums - Kotlin 中具有反向查找的有效枚举?

kotlin - Kotlin 中的多变量 let

kotlin - Kotlin 中的单个感叹号

kotlin - Kotlin 中等效的 Swift 'if let' 语句

loops - Kotlin 中 `break` 中的 `continue` 和 `forEach`