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:
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
- 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.
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?
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
Don't forget to invalidate cache if you have some trouble using File -> Invalidate Cache / Restart
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.
- 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
Set Project-level-setting "Use default Gradle wrapper (recommended)" from,
Android Studio -> File -> Setting -> Build, Exeution, Deployment -> Gradle
Set Android Studio JDK location:
Android Studio -> File -> Project Structure -> SDK Location -> JDK location
- 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
- After complete setting clean cash Android Studio will recover it own.
Android Studio -> File -> Invalidate caches/ Restart...
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.
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:
- first of all go to Gradle Distributions and download any gradle of version greater than 3.2
- extract it and save it in a suitable place in your computer.
- go to android studio and choose the following path
- File->Settings->Build,Execution,Deployment->Gradle
- on the right side choose or select Use local gradle distribution
- and then browse to where you had saved your downloaded extracted gradle
- click apply, then ok.
- 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'
来源:https://stackoverflow.com/questions/41116687/gradle-build-failing-after-update-to-android-studio-2-3-canary-3