Error: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.
In Android studio 3.0 on this problem, use the JakeWharton great god butterknife. Please how to deal with this problem, this is no problem on the Android studio 2.3. May be I used the wrong way, please advise, is originally used 8.5.1 version, an error, I upgraded to 8.6.0, found that the problem cannot be solved.
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
maven {
url 'https://maven.google.com'
}
maven {
url 'https://dl.google.com/dl/android/maven2/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1+'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
classpath ("com.tencent.mm:AndResGuard-gradle-plugin:1.2.3") { changing=true }
classpath 'com.letv.sarrsdesktop:BlockCanaryExPlugin:0.9.8.3'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
maven {
url 'http://www.idescout.com/maven/repo/'
}
maven {
url "http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories"
}
maven {
url 'https://maven.google.com'
}
maven {
url 'https://dl.google.com/dl/android/maven2/'
}
}
}
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
task printProps << {
println commandLineProjectProp
println gradlePropertiesProp
println systemProjectProp
println envProjectProp
println System.properties['system']
}
apply plugin: 'com.android.application'
//butterknife
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.jakewharton.butterknife'
/**
* library
*/
dependencies {
compile 'com.jakewharton:butterknife:8.6.0+'
apt 'com.jakewharton:butterknife-compiler:8.6.0+'
}
Downgrade butterknife-gradle-plugin to 8.4 or use 9.0 snapshot.
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'
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 below line
apply plugin: 'me.tatarka.retrolambda'
Related
While integrating WorkManager in my Application, I updated my app settings as follows:
androidMinSdkVersion = 15
androidTargetSdkVersion = 28
androidCompileSdkVersion = 28
androidBuildToolsVersion = "28.0.0"
Due to version upgrade to 28 I had to update gradle too.
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Project.gradle
buildscript {
repositories {
// Gradle 4.1 and higher include support for Google's Maven repo using
// the google() method. And you need to include this repo to download
// Android Gradle plugin 3.0.0 or higher.
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
mavenCentral()
jcenter()
gradlePluginPortal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Due to all these changes(mainly WorkManger), I had to (was forced to) upgrade the butterknife library version to 9.0.0 at least.
So I updated it as follows in my app.gradle file
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.butterknife'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0'
}
}
But whenever I try to clean-build I keep getting following error in logcat.
ERROR: Could not find com.android.tools.build:gradle:3.1.4.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.jar
Required by:
project :_btn_payment > com.jakewharton:butterknife-gradle-plugin:10.1.0
Any help is appreciated.
You should move your classpath 'com.jakewharton:butterknife-gradle-plugin:10.1.0' to Project.gradle
butterknife 10.x only supports AndroidX-enabled builds.
You will changed to version 9.0.0
From gradle gradle plugin 3.0 apt has deprecated,delete classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
library build.gradle
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.jakewharton.butterknife'
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0'
}
}
When I updated, Gradle 4.6 -> 4.10.1 and the Android Gradle plugin 3.2.1 -> 3.3.1, I get the following errors:
ERROR: Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0).
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.android.support:support-v4:[26.0.0, 27.2.0).
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.android.support:customtabs:[26.0.0, 27.2.0).
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[10.2.1, 12.1.0).
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[10.2.1, 12.1.0).
Show Details
Affected Modules: app
While inspecting dependancies I found OneSignal implementation 'com.onesignal:OneSignal:3.10.6' was throwing above errors for ex.
> Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).
Required by:
project :app > com.onesignal:OneSignal:3.10.6
> Failed to list versions for com.google.android.gms:play-services-location.
> Unable to load Maven meta-data from https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk/com/google/android/gms/play-services-location/maven-metadata.xml.
> Could not get resource 'https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk/com/google/android/gms/play-services-location/maven-metadata.xml'.
Now coming to https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk is used to fetch the dependencies required for JustPay integration.
Problem
Why wrong repository is used when resolving above dependancies for compiling the project? Am I doing something wrong or something has changed in gradle 3.3 which is causing this? Or its an issue of gradle 3.3.1?
Solution : Excluding this libs does solves the problem.
implementation ('com.onesignal:OneSignal:3.10.6') {
exclude group : 'com.google.android.gms'
exclude group : 'com.android.support'
exclude group : 'com.google.firebase'
}
I am not sure, It may have adverse affects though(If any please do let me know). But I want to get to the root of the problem I want to know why this is only happening for Android Gradle plugin 3.3.1 and the same works just fine with Android Gradle plugin 3.2.1 i.e. without excluding this dependancies.
Here is my app/build.gradle file
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "io.fabric.tools:gradle:$rootProject.fabricGradle"
}
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
apply plugin: 'project-report'
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com'
}
maven {
url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
maven {
url 'https://s3-ap-southeast-1.amazonaws.com/jp-build-packages/ec-android-sdk'
}
maven {
url 'https://s3-ap-southeast-1.amazonaws.com/godel-release/godel/'
}
}
android {
....
....
}
dependencies {
...
implementation 'com.onesignal:OneSignal:3.10.6'
...
}
build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1
classpath 'com.google.gms:google-services:4.2.0'
classpath "io.realm:realm-gradle-plugin:5.8.0"
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 {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
...
}
Update : I know it has something to do with Improved classpath synchronization which is introduced in 3.3, but still have no clue why is it trying to resolve those dependencies with wrong repository.
Update 2
I have tried following as well
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
dependencies {
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]' //as well ) at the end
}
Can you please try this:
Go to File -> Settings -> Build, Execution, Deployment -> Gradle ->
And uncheck "Offline work" option.
Update:
Remove below line of code
classpath 'com.google.gms:google-services:4.2.0'
from top-level build.gradle file sync and check it once.
In the app's build.gradle file, I have included the maven central repository and added the dependency
apply plugin: 'com.android.application'
repositories
{
mavenCentral()
}
dependencies {
compile 'org.ethereum:geth:1.8.7'
}
But the Gradle sync failed with this error
Failed to resolve: org.ethereum:geth:1.8.7
How do I fix this?
Write below code :
maven {
url "https://maven.google.com"
}
google()
instead
mavenCentral()
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.
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
seems that issue is not in app/build.gradle , but in butterknife-gradle-plugin
Solved by removing butterknife-gradle-plugin
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'
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
I use AIDE while on the go. On Android Studio I added Crashlytics to my project but upon moving it over to AIDE,it doesn't seem to recognize Crashlytics. Specifically, this line is specified as an unknown dependant according to compile error:
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true}
Is there anything I can do to fix this or is AIDE incapable of supporting Crashlytics?
Ensure you have the plugin preinstalled in Android Studio - https://fabric.io/downloads
Then in your build.gradle, add/update the following at the very top:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// Fabric
classpath 'io.fabric.tools:gradle:+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
If AIDE does not work properly, then please download the AAR library, then copy it in your /libs folder (say the name of the file is fabric-2.5.2.aar
Update build.gradle as follow:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// Fabric
classpath 'io.fabric.tools:gradle:+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
// .aar repositories
repositories {
flatDir { dirs 'libs' }
}
dependencies {
compile(name: 'fabric-2.5.2', ext: 'aar')
...
}