Gradle build failing after update to Android studio 2.3 Canary 3-ThrowExceptions

Exception or error:

I’ve recently updated the android studio version of my project from 2.3 Canary 2 to 2.3 Canary 3. Since then the gradle build is failing every time with this error:

Error:Unable to find method ‘org.gradle.api.tasks.Sync.getInputs()Lorg/gradle/api/internal/TaskInputsInternal;’.
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’ve searched google and not found solutions like this exactly but those that are similar are not working. Does anyone know how to fix it?

How to solve:

The solution is to select “Use default gradle wrapper (recommended)” option in the build gradle panel like the image below.
Now you can build with gradle 3.2 (in your gradle-wrapper.properties) and android gradle:2.3.0-alpha3 or beta1 as the time of writing

enter image description here

Don’t forget to invalidate cache if you have some trouble using File -> Invalidate Cache / Restart

###

I had the same problem, fixed with checking gradle home path. This cannary build is no more working with gradle-2.14.1

The below link shows, point gradle path to gradle 3.2 directory.

enter image description here

###

The problem is the last version of tools 2.3.0-alpha3.
Try to use the 2.3.0-alpha2 in project build.gradle

classpath 'com.android.tools.build:gradle:2.3.0-alpha2'

###

It’s mostly happened when setup new or update version of Android studio. I tried almost all solutions and find some fact that I like to share. It’s work for me.

  1. Make sure that updated JDK has set up to your computer and set path location.

Control Panel\System and Security\System-> Advanced system setting -> Advanced -> Enviroment Variables -> edit Path and pest your JDK bin folder location

Ex: C:\Program Files\Java\jdk1.8.0_131\bin

  1. Set Project-level-setting “Use default Gradle wrapper (recommended)” from,

    Android Studio -> File -> Setting -> Build, Exeution, Deployment -> Gradle

  2. Set Android Studio JDK location:

Android Studio -> File -> Project Structure -> SDK Location -> JDK location

  1. If this three thing is done then you need to set Gradle version 3.4.1 or see the latest version from gradle.org/releases.

Android Studio -> File -> Project Structure -> Project -> Gradle Version

  1. After complete setting clean cash Android Studio will recover it own.

Android Studio -> File -> Invalidate caches/ Restart…

enter image description here

###

If you’re using the gradle wrapper, make sure that the distributionUrl in your gradle/wrapper/gradle-wrapper.properties is correct and up to date. As of this writing, I use this:

 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
 distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

###

try upgrading the Gradle version to 3.2.1

###

You may face this problem with your previous Project, We will notice that when you create a new application the Gradle build will complete successfully.
So just copy paste the grade setting from new project to the previous project.

Steps:

1) Replace Dependencies in build.gradle (project) by this code :

classpath ‘com.android.tools.build:gradle:2.3.0’

2) Replace distributionUrl in Gradle-wrapper.properties by this code:

distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip

3) Don’t forget to use Gradle default wrapper in Project level setting.

See this picture for more information

###

When updating to android studio 2.3, and then load an existing project for older version of android studio, It might take long if not forever on refreshing project.
I had the same problem but i fixed it as follows:

  1. first of all go to Gradle Distributions and download any gradle of
    version greater than 3.2
  2. extract it and save it in a suitable place in your computer.
  3. go to android studio and choose the following path
  4. File->Settings->Build,Execution,Deployment->Gradle
  5. on the right side choose or select Use local gradle distribution
  6. and then browse to where you had saved your downloaded extracted
    gradle
  7. click apply, then ok.
  8. thats it, your project should now work normally.

###

change

build:gradle:

from

dependencies {
classpath ‘com.android.tools.build:gradle +’

to

dependencies {
classpath ‘com.android.tools.build:gradle:2.2.3’

Leave a Reply

Your email address will not be published. Required fields are marked *