尝试使用Android Studio 3.0 Canary 1启动新的Kotlin项目会显示此错误 . 完整跟踪:
错误:无法找到方法'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava / util / List;' . 此意外错误的可能原因包括:Gradle的依赖性缓存可能已损坏(这有时会在网络连接超时后发生 . )重新下载依赖项和同步项目(需要网络)Gradle构建过程(守护程序)的状态可能已损坏 . 停止所有Gradle守护进程可以解决此问题 . 停止Gradle构建过程(需要重新启动)您的项目可能正在使用第三方插件,该插件与项目中的其他插件或项目请求的Gradle版本不兼容 . 在损坏的Gradle进程的情况下,您还可以尝试关闭IDE,然后终止所有Java进程 .
我尝试了前两个选项,第三方插件保留为默认值 .
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新项目没有这个问题 .
6 回答
将您的kotlin版本更新为最新版本:
然后您可能会遇到更多错误,因此在再次同步之前,请确保
buildToolsVersion
是"26.0.2"或更高 .在我的情况下,问题是由于我们正在应用butterknife-gradle-plugin引起的 . 升级到8.8.1并没有解决问题,但删除它肯定会 .
build.gradle属于应用程序,所以我不喜欢该项目的新手 . )
在我的_2850694改变
ext.kotlin_version = '1.1.2-3'
至
ext.kotlin_version = '1.1.2-4'
修好了 .
你可以找到最新版本here .
For Java
只需删除
将
butterknife
版本降级为8.4.0
别忘了删除
apply plugin: 'me.tatarka.retrolambda'
从应用程序级别构建gradle .
它对我有用
使用8.4.0版本
这是Android Studio Preview 3.0中的known issue: