Unable to find method 'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'
Asked Answered
F

4

8

build.gradle

buildscript {
    ext.kotlin_version = '1.1.51'
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'me.tatarka:gradle-retrolambda:3.6.1'
        classpath 'com.google.gms:google-services:3.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

app/build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.7.0'
    }
}


      android{
            compileSdkVersion = 26  
            buildToolsVersion = "26.0.2"
    defaultConfig {
            minSdkVersion = 16
            targetSdkVersion = 26

        }
    ...
    applicationVariants.all { variant ->

        variant.outputs.all { output ->
            outputFileName = "newApkName.apk"
        }
    }
}

How to solve issue:

Unable to find method 'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'.

Possible causes for this unexpected error include: 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. In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Frear answered 26/10, 2017 at 7:44 Comment(2)
You can post your solution as an answer so that the question doesn't look like unanswered for the people who are looking to offer help.Meniscus
I found the easiest way is to "remove butterknife", it may cost you few minutes, but with butterknife, you'll spend weeks to pass compilingScever
S
11

I had the same error with gradle syncing, specifically tied to butterknife, my solution was solved via

https://github.com/JakeWharton/butterknife/issues/963#issuecomment-339545297

tldr in your project build file...

buildscript{
 repositories {
   //other repos will likely exist here like jcenter and mavenCentral

   //add this closure
   maven {
    url "https://oss.sonatype.org/content/repositories/snapshots"
   }
  }
   dependencies {
    classpath 'com.jakewharton:butterknife-gradle-plugin:8.7.0'
    classpath 'com.android.tools.build:gradle:3.0.0'
    //change your version to 9.0.0-SNAPSHOT
     classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
    //.. other project level dependencies 
   }
 }
}

Also make sure your allproject includes

allproject{
  repositories{
    maven {
      //this
      url "https://oss.sonatype.org/content/repositories/snapshots"
    }
   }
 }

And then the none butterknife related issue was upping my buildToolsVersions to "26.0.2" in your app build file

UPDATE 4/19/2018 Have since parted ways with butterknife as it has since caused more issues than any other 3rd party I've used. Besides, with full Kotlin support, butterknife isn't necessary

Salpingitis answered 26/10, 2017 at 13:16 Comment(1)
In my library project (R2 imports) this comment helped me: github.com/JakeWharton/butterknife/issues/…Podite
F
0

seems that issue is not in app/build.gradle , but in butterknife-gradle-plugin

Solved by removing butterknife-gradle-plugin

Frear answered 26/10, 2017 at 12:58 Comment(0)
P
0

Based on ElliotM's answer:

  • Kotlin 1.2.10
  • Gradle 3.0.1
  • Build tools version 27.0.3
  • apply plugin: 'com.android.library'
  • apply plugin: 'kotlin-android-extensions'
  • apply plugin: 'kotlin-android'
  • apply plugin: 'com.jakewharton.butterknife'

In my library project this comment helped me (R2 imports): https://github.com/JakeWharton/butterknife/issues/963#issuecomment-342547601

project's build.gradle:

buildscript {
    repositories {
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
    }
}

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

module's build.gradle:

apply plugin: 'com.jakewharton.butterknife'

...

dependencies {
    compile 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
    kapt 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
}

This way you can use the

apply plugin: 'com.jakewharton.butterknife'
Podite answered 4/1, 2018 at 13:34 Comment(0)
A
0

My solution was to upgrade gradle in my project

from : com.android.tools.build:gradle:3.1.4

to : com.android.tools.build:gradle:3.5.3

Annieannihilate answered 11/2, 2020 at 20:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.