简体   繁体   中英

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

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.

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

只需转到文件 -> 使缓存无效/重新启动 -> 无效并重新启动

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

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

.

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.

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

在此处输入图片说明

First check why the build is failing, in my case it was that I had not accepted licenses for platform 29 and by default platform 30 was installed. To fix this I went to tools >> sdk manager then installed pplatform 29 and accepted licenses [ALL GUI]. It was solved after that.

Files > Settings > Appearance & Behavior > System Settings > android SDK > SDK Platform.

From SDK Platform Select and Install Latest API Level (31) SDK.

After Successfully Installation Restart Android Studio.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM