尝试使用 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:
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
- 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.
我已经尝试了前两个选项,第三方插件保持默认。
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/