2

I tried to update the gradle version in my project to 4.1-milestone-1 following these instructions

My current gradle-wrapper.properties file:

#Sat Jun 17 21:17:43 IDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=\
  https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip

My current project build.gradle file buildscript

buildscript {
    ext.kotlin_version = '1.1.3'
    apply from: 'dependencies.gradle'
    repositories {
        jcenter()
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
        ....
    }
    ....
}

When trying to compile the project I get this error:

Error:(1, 0) Unable to find method 'com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V'. 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 tried cleaning the project

  • I tried to click re-download dependencies and sync project, but I get the same error.

  • I deleted my previous .gradle file in my home directory and in my project but I get the same error.

  • I tried killing the java process and android studio but I get the same error.

  • I tried killing all gradle's daemons but I get the same error

Rosenpin
  • 862
  • 2
  • 11
  • 40
  • You've tried everything so may be 3rd reason is the problem `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.` – Abhishek Aryan Jul 01 '17 at 16:32
  • 1
    How can I figure out which plugin it is? – Rosenpin Jul 01 '17 at 16:47

1 Answers1

4

The problem was that I had firebase in my buildscript dependencies, so it looked something like this:

buildscript {
    ext.kotlin_version = '1.1.3-2'
    apply from: 'dependencies.gradle'
    repositories {
        ...
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
        classpath ('com.google.firebase:firebase-plugins:1.1.0') //the firebase line
        ....
    }
}

I finally solved the issue by replacing the firebase classpath line with this:

classpath ('com.google.firebase:firebase-plugins:1.1.0') {
    exclude group: 'com.google.guava', module: 'guava-jdk5'
}

So now my gradle build script looks something like this

 buildscript {
        ext.kotlin_version = '1.1.3-2'
        apply from: 'dependencies.gradle'
        repositories {
            ...
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.0-alpha6'
            classpath ('com.google.firebase:firebase-plugins:1.1.0') {
                exclude group: 'com.google.guava', module: 'guava-jdk5'
            }
            ....
        }
    }

After that, all I had to do was clean the project, kill the gradle daemon

./gradlew --stop

And restart studio, and the issue was solved.

Rosenpin
  • 862
  • 2
  • 11
  • 40
  • 1
    Can you explain why excluding **guava** worked ? I also have the Firebase plugin and after including your lines it built without any errors. – vovahost Jul 15 '17 at 22:04
  • Source : https://github.com/firebase/quickstart-android/issues/271#issuecomment-304424918 Ref: https://stackoverflow.com/questions/44104374/unable-to-compile-under-android-studio-3-0-canary-1#comment76853207_44218754 – Sungam Jul 17 '17 at 22:15