[英]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: 此意外错误的可能原因包括:
None of the proposed solutions worked. 所提出的解决方案都没有奏效。 I also tried invalidating caches and manually deleting Gradle caches to force redownload of dependencies and wrapper.
我还尝试使缓存无效并手动删除Gradle缓存以强制重新下载依赖项和包装器。
EDIT: "Upgrading to the latest build tools and Gradle version" is not a solution because this issue still exists. 编辑: “升级到最新的构建工具和Gradle版本” 不是一个解决方案,因为这个问题仍然存在。 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.
由于该问题最初是在6个月前报告的(尽管它被分类为“关键”),但解决方法不仅是坏的,而且不是暂时的。
The problem seems to be solved for me. 这个问题似乎已经解决了。 This is what I did, including my conjecture as to why it worked.
这就是我所做的,包括我猜测它为何起作用。
'com.android.tools.build:gradle:2.3.0'
) 'com.android.tools.build:gradle:2.3.0'
) Having done that, Android Studio finally condescended to sync my project. 完成后,Android Studio终于屈服于同步我的项目。 HOWEVER, when I actually attempted to build the project, I ran into this well known bug .
但是,当我真正尝试构建项目时,我遇到了这个众所周知的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. 确认错误仍然存在于最新的构建工具中,我解除了我的更改并让AS再次同步我的项目。 Voilà, it worked.
Voilà,它奏效了。
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. 我推测这次工作有效,因为更改构建工具两次强制了一些文件系统更改,当我只删除
~/.gradle/caches/
和~/.gradle/daemon/
目录中的某些目录时,我错过了这些更改。
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. 如果我在这听起来很讽刺,我道歉,但Android Studio团队发布他们的IDE的“稳定”版本是非常令人沮丧的,这个版本没有文档记录,(接近?)破坏性更改。 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.
他们试图强制“升级”到具有已知严重缺陷的构建工具(哦,但它只是测试,谁在乎呢?)是错的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.