Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Sync Failed - Android Studio 2.3.1

Tags:

java

android

My code was working fine before the update. But after i updated to 2.3.1, it started to give the following error,

    Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>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.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Please help.

like image 747
Mano Haran Avatar asked Nov 29 '22 09:11

Mano Haran


1 Answers

Finally found a solution for this.

Specify the gradle version. You can specify the Android plugin for Gradle version in either the File > Project Structure > Project menu in Android Studio, or the top-level build.gradle file. The plugin version applies to all modules built in that Android Studio project. The following example sets the Android plugin for Gradle to version 2.3.1 from the build.gradle file:

 buildscript {
  ...
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.1'
  }
}

Source : enter link description here

like image 123
Mano Haran Avatar answered Dec 04 '22 14:12

Mano Haran