AutonomousApps
AutonomousApps

Reputation: 4389

Can't sync Gradle after upgrading to Android Studio 2.3

This happens every so often, but I can't seem to resolve it this time. Project builds fine from the command line. This is the 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:

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.


None of the proposed solutions worked. I also tried invalidating caches and manually deleting Gradle caches to force redownload of dependencies and wrapper.

EDIT: "Upgrading to the latest build tools and Gradle version" is not a solution because this issue still exists. And the current workaround to that issue is to disable test coverage "temporarily." As that issue was originally reported 6 months ago (and despite it's being triaged as "critical"), the workaround is not only bad, but not temporary.

Upvotes: 3

Views: 3403

Answers (1)

AutonomousApps
AutonomousApps

Reputation: 4389

The problem seems to be solved for me. This is what I did, including my conjecture as to why it worked.

  1. I 'upgraded' my project's Android Gradle Build Tools from 2.1.2 to 2.3.0 ('com.android.tools.build:gradle:2.3.0')
  2. I upgraded my Gradle wrapper from 2.14 to 3.3
  3. I upgraded my buildToolsVersion from 23.0.3 to 25.0.0.

Having done that, Android Studio finally condescended to sync my project. HOWEVER, when I actually attempted to build the project, I ran into this well known bug. I refuse to 'workaround' this bug, because disabling test coverage is a non-starter.

Having confirmed that bug still holds in the latest build tools, I undid my changes and let AS sync my project again. Voilà, it worked.

I speculate that it worked this time because changing the build tools twice forced some filesystem changes that I missed when I simply deleted some directories in my ~/.gradle/caches/ and ~/.gradle/daemon/ directories.

If I sound at all snarky in this, I apologize, but it's incredibly frustrating for the Android Studio team to release a 'stable' version of their IDE that has undocumented, (near?) breaking changes. For them to attempt to force an 'upgrade' to a build tool that has a known critical defect (oh, but it's only testing, and who cares about that?) is just wrong.

Upvotes: 5

Related Questions