java Gradle 同步失败 - Android Studio 2.3.1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43243033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle Sync Failed - Android Studio 2.3.1
提问by Mano Haran
My code was working fine before the update. But after i updated to 2.3.1, it started to give the following error,
我的代码在更新之前运行良好。但是在我更新到 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.
Please help.
请帮忙。
回答by Mano Haran
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:
指定 gradle 版本。您可以在 Android Studio 的 File > Project Structure > Project 菜单或顶级 build.gradle 文件中为 Gradle 版本指定 Android 插件。插件版本适用于该 Android Studio 项目中构建的所有模块。以下示例从 build.gradle 文件将 Gradle 的 Android 插件设置为版本 2.3.1:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
}
Source : enter link description here
来源:在此处输入链接描述