Gradle 3.0.0-alpha1与kotlin-android插件1.1.2-3不兼容?

我安装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进程。

如果我从build.gradle中删除kotlin-android插件,那么它将成功构建。

构建gradle:

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 } 

应用程序\的build.gradle

 apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig { applicationId "com.dmytrobazunov.databasetest" minSdkVersion 15 targetSdkVersion 25 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" compile 'com.android.support:appcompat-v7:25.3.1' testCompile 'junit:junit:4.12' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:design:25.3.1' } 

有人知道如何解决这个问题?

您需要将Kotlin插件版本更改为1.1.2-4

从以前版本的Android Studio中导入设置时会发生这种情况。 把你的kotlin插件版本升级到1.1.2-4并删除文件夹~/Library/Application Support/AndroidStudioPreview3.0/Kotlin (如果你使用的是mac)