Gradle同步失败 - Android Studio 2.3.1

4

在更新之前,我的代码运行良好。但是在我更新到2.3.1版本后,它开始出现以下错误:

    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.

请帮个忙。

1个回答

21

最终找到了解决方案。

指定Gradle版本。您可以在Android Studio的“文件”>“项目结构”>“项目”菜单中,或者在顶层build.gradle文件中指定Gradle版本。插件版本适用于在该Android Studio项目中构建的所有模块。以下示例将Gradle的Android插件版本从build.gradle文件设置为2.3.1:

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

来源: 点击这里进入链接描述


1
将 classpath 更新为最新兼容版 gradle(例如:classpath 'com.android.tools.build:gradle:2.4.0-alpha7'),并将 buildToolsVersion 更新至 25,问题得以解决。谢谢! - NightFury

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接