Android Studio 3.1 Canary 3 - Gradle sync failed

Viewed 18198

For a unknown reason Android Studio 3.1 Canary 3 is bugged and stopped to work, I updated gradle to 3.1-alpha03 and it stopped working, no matter if I download the project again, already downloaded Android Studio again too.

I've already checkout old versions of the project, but this message still show:

Gradle sync failed: com.android.tools.idea.gradle.project.model.AndroidModuleModel.getSelectedVariant()Lcom/android/tools/idea/gradle/project/model/ide/android/IdeVariant; (8s 806ms)

I've removed .idea folder, .gradle folder, did invalidate and restart

I don't know nothing more to do, cant run or use the IDE.


Edit:

Image


Edit2:

New Projects doesnt work too

8 Answers

To solve this issue, you have to either upgrade or downgrade your kotlin plugin

Solution 1: Upgrade Plugin

First go to Tools menu > Select Kotlin > Configure Kotlin Plugin Updates > Select one of the kotlin plugin & press download (stable or early access, i chose early access to solve this issue)

And finally change the kotlin version in build.gradle(Project:) according to the downloaded version


enter image description here

Solution 2: Downgrade Plugin

If your on mac then press: Command + , to open preference, then select plugin & search for kotlin & uninstall it, it will rollback to previous version: 1.1.51

On Windows machine, press Control + Alt + S to open settings dialog, then select plugins & search for kotlin & uninstall it, it will rollback to previous version: 1.1.51

enter image description here

Please Note: Do not uncheck kotlin in plugins else it will disable kotlin & fail to recognise kotlin file & syntax

Try to download and install this kotlin plugin for android studio 3.1

on Windows i just remove from C:\Users\ folder -

.AndroidStudioPreview3.1

and all cache folders in .android ,.gradle too

and problem is gone)

solved:

first run -> find ~ -path ~/Library/Caches/Metadata/Safari -prune -o -iname \*android\*studio\* -print -prune

DELETE ALL FOLDERS related to android-studio

start fresh install and project setup

roll back to the previous gradle version i have faced such issues myself and stay away from RC gradle version unless really needed.

Related