Android Studio 2.2.3: Gradle project sync failed. Basic functionality (e.g. editting, debugging) will not work properly

帅比萌擦擦* 提交于 2020-06-25 19:06:44

问题


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:

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

I did all the three steps suggested by Android Studio to fix my project, but none of them worked.


回答1:


Your gradle version is: 1.8 which is not working anymore so you probably have to update it:

1- Go to -> https://gradle.org/install check out the latest verion number.

2- In your project directory navigate to \gradle\wrapper\ directory and edit: gradle-wrapper.properties file.

change:

https://services.gradle.org/distributions/gradle-1.8-all.zip

to:

https://services.gradle.org/distributions/gradle-3.3-all.zip

3- go to Tools→Android→Sync Project with Gradle files

4- If sync doesn't do the job restart Android studio




回答2:


Just go to file -> Invalidate Caches/Restart -> Invalidate and Restart




回答3:


Update your 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.

Below Website gives a detailed explanation on how to update gradle and gradle plugin of Android Studio.

Update gradle plugin Android Studio




回答4:


This error also occurs when Android Studio is working offline.

To check this below points:

  • 1.Open the Preferences window by

clicking File > Settings (on Mac, Android Studio > Preferences).

  • 2.In the left pane,

click Build, Execution, Deployment > Gradle.

  • 3.Check the Offline work checkbox. If it is checked then Android Studio is working offline you have to unchecked it.

  • -

4.Click Apply or OK

.




回答5:


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 Studio will suggest you updates and you have to update by clicking on the notification inside android studio at the bottom.

Automatically the above error will be resolved for you.




回答6:


Settings > Experimental > turn off "Only sync the active variant"



来源:https://stackoverflow.com/questions/42190540/android-studio-2-2-3-gradle-project-sync-failed-basic-functionality-e-g-edit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!