Android Studio 3.0 - Unable to find method 'com.android.build.gradle.internal.variant.BaseVariantData.getOutputs()Ljava/util/List'

Android StudioKotlin

Android Studio Problem Overview


Trying to start a new Kotlin project with Android Studio 3.0 Canary 1 displays this error. Full trace:

> 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.

I've tried the first two options and the third-party plugins are left as default.

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
}

I haven't touched any of these values myself, they're left as default. Creating a non-Kotlin new project does not have this problem.

Android Studio Solutions


Solution 1 - Android Studio

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.

Solution 2 - Android Studio

It worked for me

Using the 8.4.0 version

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

Solution 3 - Android Studio

For Java

Just remove

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

downgrade butterknife version 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.

Solution 4 - Android Studio

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/

Solution 5 - Android Studio

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)

Solution 6 - Android Studio

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJosh LairdView Question on Stackoverflow
Solution 1 - Android StudioJosh LairdView Answer on Stackoverflow
Solution 2 - Android StudioJustcuriousView Answer on Stackoverflow
Solution 3 - Android StudioAks4125View Answer on Stackoverflow
Solution 4 - Android StudioRenan FerrariView Answer on Stackoverflow
Solution 5 - Android StudioMaraguesView Answer on Stackoverflow
Solution 6 - Android StudioDuskView Answer on Stackoverflow