Java Android Studio 2.2.3:Gradle 项目同步失败。基本功能(例如编辑、调试)将无法正常工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42190540/
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
Android Studio 2.2.3: Gradle project sync failed. Basic functionality (e.g. editting, debugging) will not work properly
提问by Victoria
I needed to preinstall my laptop and switched to Windows 10 . Before that I made and saved my project in Android Studio 2.2.3 and I downloaded the same version of Android Studio after preinstallation, but when I choose Open Existing Project I got the following message:
我需要预装我的笔记本电脑并切换到 Windows 10 。在此之前,我在 Android Studio 2.2.3 中创建并保存了我的项目,并在预安装后下载了相同版本的 Android Studio,但是当我选择 Open Existing Project 时,我收到以下消息:
Failed to sync gradle project 'ApplicationName' Error:Unable to find method 'org.gradle.api.artifacts.Configuration.setExtendsFrom(Ljava/lang/Iterable;)Lorg/gradle/api/artifacts/Configuration;'.
Possible causes for this unexpected error include: Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
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. Blockquote
无法同步 gradle 项目“ApplicationName”错误:无法找到方法“org.gradle.api.artifacts.Configuration.setExtendsFrom(Ljava/lang/Iterable;)Lorg/gradle/api/artifacts/Configuration;”。
此意外错误的可能原因包括:Gradle 的依赖项缓存可能已损坏(这有时会在网络连接超时后发生。)
Gradle 构建进程(守护进程)的状态可能已损坏。停止所有 Gradle 守护进程可能会解决这个问题。
您的项目可能使用了第三方插件,该插件与项目中的其他插件或项目要求的 Gradle 版本不兼容。块引用
I did all the three steps suggested by Android Studio to fix my project, but none of them worked.
我做了 Android Studio 建议的所有三个步骤来修复我的项目,但它们都不起作用。
采纳答案by Ahmad Sanie
Your gradle version is: 1.8
which is not working anymore so you probably have to update it:
您的 gradle 版本是:1.8
不再工作,因此您可能必须更新它:
1-Go to -> https://gradle.org/installcheck out the latest verion number.
1-前往 -> https://gradle.org/install查看最新版本号。
2-In your project directory navigate to \gradle\wrapper\
directory and edit:
gradle-wrapper.properties
file.
2-在您的项目目录中导航到\gradle\wrapper\
目录并编辑:
gradle-wrapper.properties
文件。
change:
改变:
https://services.gradle.org/distributions/gradle-1.8-all.zip
to:
到:
https://services.gradle.org/distributions/gradle-3.3-all.zip
https://services.gradle.org/distributions/gradle-3.3-all.zip
3-go to Tools→Android→Sync Project with Gradle files
3-转到工具→Android→使用 Gradle 文件同步项目
4-If sync doesn't do the job restart Android studio
4-如果同步没有完成工作,请重新启动 Android Studio
回答by Mahdi
Update your gradle.
更新你的gradle。
Open File > Project Structure > Project Tab
打开文件 > 项目结构 > 项目选项卡
Android Studio has built in project structure menu to check and update gradle and plugin used in the current project.
Android Studio 内置了项目结构菜单,用于检查和更新当前项目中使用的 gradle 和插件。
Below Website gives a detailed explanation on how to update gradle and gradle plugin of Android Studio.
下面的网站详细解释了如何更新 Android Studio 的 gradle 和 gradle 插件。
回答by Bilal Ahmad
Just go to file -> Invalidate Caches/Restart -> Invalidate and Restart
只需转到文件 -> 使缓存无效/重新启动 -> 无效并重新启动
回答by M_S_Soni
This error also occurs when Android Studio is working offline.
当 Android Studio离线工作时也会发生此错误。
To check this below points:
要检查以下几点:
- 1.Open the Preferences window by
- 1.打开首选项窗口
clicking File > Settings (on Mac, Android Studio > Preferences).
单击文件 > 设置(在 Mac 上,Android Studio > 首选项)。
- 2.In the left pane,
- 2.在左窗格中,
click Build, Execution, Deployment > Gradle.
单击构建、执行、部署 > Gradle。
3.Check the Offline work checkbox. If it is checked then Android Studio is working offline you have to unchecked it.
-
3. 选中离线工作复选框。如果选中,则 Android Studio 正在脱机工作,您必须取消选中它。
——
4.Click Apply or OK
4.点击应用或确定
.
.
回答by Shrinivas
The error is thrown because google has updated the android plugin and gradle integration. You have to update android studio to the latest one.
抛出错误是因为谷歌更新了android插件和gradle集成。您必须将 android studio 更新到最新版本。
Android Studio will suggest you updates and you have to update by clicking on the notification inside android studio at the bottom.
Android Studio 会建议您更新,您必须通过单击底部 android studio 内的通知进行更新。
Automatically the above error will be resolved for you.
上述错误将自动为您解决。