21

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

Thomas Rollet
  • 1,573
  • 4
  • 19
  • 33
Tarcisio Wensing
  • 422
  • 1
  • 3
  • 13

8 Answers8

25

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

scana
  • 2,785
  • 2
  • 25
  • 49
  • 2
    Yes, after installing older version (1.1.51-release-Studio3.0-1) the error is gone. I had to download in manually and install plugin from disk. – CoPLaS Nov 15 '17 at 11:23
  • 2
    I was pulling my hair for couple of hours and this answer saved the day. Wondering what went wrong with the built in plugin. – Rinav Nov 20 '17 at 05:55
  • After 4 hours got solution, Thank you for saving time. – Pratik Butani Mar 23 '18 at 12:30
22

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

Arshak
  • 3,197
  • 1
  • 25
  • 33
  • 1
    Better than the selected answer. – Ben Dec 05 '17 at 21:40
  • 1
    The first option worked for me. After upgrading the Kotlin plugin, I was then asked to download a different version of Android build tools, but eventually the project sync succeeded. What I don't understand is why this sort of problem happens all the time with Android Studio. I have used Eclipse for many years, and it almost always works when upgrading to a new version. I have used Android Studio a lot since it was first released, and rarely have I been able to open an existing project with a new version of Android Studio. This kind of problem happens all the time with Android Studio. – John Moore Mar 29 '18 at 10:58
  • I totally agree with you – Arshak Mar 29 '18 at 11:19
6

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

Vladislav
  • 1,236
  • 13
  • 22
2

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

.AndroidStudioPreview3.1

and all cache folders in .android ,.gradle too

and problem is gone)

2

Faced same problem after upgrading to Android Studio 3.1 stable.

Kotlin plugin version was 1.2.30-release-Studio3.1-1

So manually upgraded to,

1.2.31-release-Studio3.1-1

and boom, problem solved.

In short, try upgrading to most relevant plugin to fix gradle sync failure.

Rahul Patel
  • 607
  • 8
  • 10
  • Also, It requires: classpath 'com.android.tools.build:gradle:3.1.0' in build.gradle files (app and project); min build tools version: buildToolsVersion '27.0.3' ; distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip in the gradle-wrapper.properties; And !important! uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library [com.android.databinding:adapters:3.1.0] ...\.gradle\caches\transforms-1\files-1.1\adapters-3.1.0.aar\7631a24d9a29d78db9b47614fb87e2a8\AndroidManifest.xml as the library might be using APIs not available in 9 – Sergio Mar 30 '18 at 07:04
1

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

Tarcisio Wensing
  • 422
  • 1
  • 3
  • 13
1

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

amIT
  • 664
  • 13
  • 27
1

I encountered the same problem after upgrading to:

Android Studio 3.2 Canary 10
Build #AI-181.2784.17.32.4705630, built on April 6, 2018
JRE: 1.8.0_152-release-1136-b02 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.4

& Kotlin plugin 1.2.31

I uninstalled the Kotlin plugin

File | Invalidate Cache and restart

Reinstalled the latest Kotlin plugin 1.2.31

File | Invalidate Cache and restart

Everything is now okay.

NOTiFY
  • 1,255
  • 1
  • 20
  • 36