Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 3.1 Canary 3 - Gradle sync failed

Tags:

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

like image 937
Tarcisio Wensing Avatar asked Nov 14 '17 16:11

Tarcisio Wensing


People also ask

How do I sync gradle with Android Studio?

Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.

Why is my gradle not syncing?

For this, you have to connect your PC to the internet and you have to open your Android studio. After opening your project click on the Sync Project with Gradle files option. This will automatically download the new Gradle files and will fix the issue which is caused by the Gradle files.


2 Answers

It's a problem with Kotlin 1.1.60-release-Studio3.0-1 plugin.

Uninstall it from Android Studio and fetch an older version from here: https://plugins.jetbrains.com/plugin/6954-kotlin

like image 164
scana Avatar answered Sep 21 '22 05:09

scana


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

like image 24
Arshak Avatar answered Sep 23 '22 05:09

Arshak