Android Studio 3.0-无法找到“ com.Android.build.gradle.interal.varient.BaseVariantData.getOutput() Ljava/util/List”方法

尝试使用 Android Studio 3.0启动一个新的 Kotlin 项目时,金丝雀1显示此错误:

错误: 无法找到方法 ‘ com.android.build.gradle.interal.varient.BaseVariantData.getOutput () Ljava/util/List;’。 这个意外错误的可能原因包括: < ul > < li > Gradle’s 依赖性缓存可能已损坏(这种情况有时发生在网络之后) 连接超时。)重新下载依赖项 和同步项目(需要网络) 构建进程(守护进程)可能已损坏。停止所有 Gradle 守护进程可能 解决这个问题。停止格拉德尔建设 进程(需要重新启动) < li > 您的项目可能正在使用 与其他插件不兼容的第三方插件 的项目或格拉德尔的版本所要求的 对于已损坏的 Gradle 进程,您可以 也可以尝试关闭 IDE,然后杀死所有 Java 进程。

我已经尝试了前两个选项,第三方插件仍然是默认的。

梯级包装纸,性能

#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

建造,分级

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

20294 次浏览

In my build.gradle changing

ext.kotlin_version = '1.1.2-3'

to

ext.kotlin_version = '1.1.2-4'

fixed this.

You can find the most recent version here.

This is a known issue in Android Studio Preview 3.0:

If you see this error, it's possible you have a pre-existing version of the Kotlin plugin that is incompatible with the new Android Plugin for Gradle that's in Android Studio 3.0. The solution is to delete the old Kotlin plugin.

Open your project-level build.gradle file and locate ext.kotlin_version. It should be 1.1.2-4 (or higher). If it shows an older version, you need to delete the old Kotlin plugin so it does not obstruct the version included with Android Studio 3.0.

On Windows, it should be located at

C:\Users\user_name\AndroidStudio_version\config\plugins\Kotlin\

On Mac, look in

~/Library/Application\ Support/AndroidStudio_version/Kotlin/

In my case, the issue was caused because we were applying butterknife-gradle-plugin. Upgrading to 8.8.1 didn't fix the issue, but removing it certainly did.

The build.gradle belongs to the application, so I don't even know why we are using that plugin (I'm new to the project)

It worked for me

Using the 8.4.0 version

 classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'

For Java

Just remove

classpath 'me.tatarka:gradle-retrolambda:3.7.0'

downgrade butterknifeversion to 8.4.0

classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'

Don't forget to remove

apply plugin: 'me.tatarka.retrolambda'

from app level build gradle.

Update your kotlin version to the latest:

ext.kotlin_version = '1.1.2-4' //currently it's the latest version

Then you may face some more errors, so before syncing again, make sure that your buildToolsVersion is "26.0.2" or higher.