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:
Edit2:
New Projects doesnt work too
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
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
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
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)
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.
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.
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.
Related
Situation and Problem
I have been working with Android Projects using android studio for a while in Java. Recently, I have started learning Flutter and therefore added Flutter modules into Android Studio.
I opened both Android Project and Flutter Project at the same time in different windows and both project can share the same emulator, and everything seemed to work fine. Yet, the next day I opened the Android Project again, the WHOLE IDE was configured with Flutter settings. This means that:
1. Android Project is NOT synced with gradle, and thus all the imports failed marked red
2. All gradle related files are not visible in the project folder in Android Studio (still exists in folder)
3. All gradle operations are gone because the IDE is configured for Flutter. So there is no rebuild project/clean project/ sync with gradle files button
Things I have tried
Reopen the project
Invalidate cache and restart
Restart PC
But none of them seemed to work. If I tried to create a new Android Project, the new Android Project seems to work fine with all gradle operations available.
Android Studio Versions
Android Studio 3.4
JRE: 1.8.0_152-release-1343-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I tried to look for similar issues but none seems to match this one. Any one can help?
I had a similar issue. Yesterday, I updated Android Studio to 3.6.1 and that fixed it. Try that.
I found the workaround solution is to import the project again instead of opening the project.
When importing, remember to choose opening it as an Android Gradle Project.
I'm fairly new to using android studio, and I can't seem to wrap my head around what i'm doing wrong.
I'm currently trying to install the Ping Plugin from Cordova, now everytime I try and install it I get the error message
Minimum supported Gradle version is 4.4. Current version is 4.1. If using the gradle wrapper, try editing the distributionUrl in /Users/sam/Development/Apps/ghost/gradle/wrapper/gradle-wrapper.properties to gradle-4.4-all.zip
So from here I go to File > Project Structure > Project and change the Gradle version to 4.4 and the Android Plugin version to 3.1.1. I then let android studios build and do what it needs to do.
From here I check the gradle-wrapper.properties file and can confirm it says 4.4-all.zip.
I then try and reinstall the plugin, it then throws the same error, so I check my gradle-wrapper.properties file and it resets itself back to 4.1!
Am I doing something stupid?
Again i'm very new to Android Studios, so apologies if i've missed anything.
Incase it helps, some extra details are
OS - macOS High Sierra 10.13.4
Homebrew - Global machine Gradle version 4.7
Android OS - 6.0.1
Cordova - 8.0.0
EDIT
Something else I have noticed, If I go into the .gradle folder in my application, and remove the 4.1 folder and try to install the plugin, it automatically recreates the 4.1 folder and uses it?
Also i've now noticed it has this behaviour every time I run any cordova command, including cordova build android
For anyone else experiencing this behaviour, once I found out that it was any cordova command that was causing the gradle to reset, It was easy to find the answer.
Answer
Basically there is a distributionUrl located inside the GradleBuilder.js file that kept on resetting my gradle back to 4.1. This needed to be changed to 4.4 and the build and plugins worked straight away!
"Moral of this particular story, for me anyway, don't update Android Studio for no good reason" - This should be made the 11th Commandment. I was able to fix this issue by deleting the /platform/android folder and re-installing it making sure not to click on any "highly recommend" upgrade options.
In addition to the answer above and listed in the path below,
Cordova build changes distributionUrl in gradle-wrapper.properties file
I found that on Android Studio 3.1.2, it is necessary to update not just GradleBuilder.js as per all previous advice, but also StudioBuilder.js.
Just to be clear, both files are in the same directory:
$PROJECT_ROOT/platforms/android/cordova/lib/builders/
and the text to be changed in this instance is
'https\://services.gradle.org/distributions/gradle-4.1-all.zip' to
'https\://services.gradle.org/distributions/gradle-4.4-all.zip'
Moral of this particular story, for me anyway, don't update Android Studio for no good reason, as it'll take up 3 hours of your day fixing sh*t. Wait till Cordova has been upgraded to suit before even thinking about it.
After updating Android Studio to version 2.2 (on Windows 10) and somehow next morning I received such error when gradle built on any project:
Write access is allowed from event dispatch thread only
Despite that gradlew -build command worked and completed successfully.
I tried typical Android dev's of WTF repairing set: clean build, invalidate caches, removing build folders, removing .gradle folder, tried different gradle settings, even reinstalling Android Studio and nothing helped.
I've created this question only to share my experience with community, because I wasted two hours on it.
So the problem was concluded in that Android Studio conflicted with my installed JDK version, so it was resolved when I checked JDK location (File → Project Structure → SDK Location), ticked 'Use embedded JDK' checkbox and set JDK location to 'path to Android Studio'\Android Studio\jre
Problem was occurred when android studio conflict with installed jdk
version, Go to the (File -> Project Structure -> SDK Location), check
'Use embedded JDK' checkbox and set jdk location to 'path to android
studio'\Android Studio\jre :) Simple
that didn't work for me, i ran a 'gradle clean build' command, i figured out that there's a conflict in a line in the gradle, deleted it and sync project (as in this pic)
My issue was that I had removed the SDK I was using while clearing up hard drive space.
To fix this, first check what SDKs you have installed, or install one in Tools > SDK Manager.
You can then change the compileSdkVersion and targetSdkVersion in app build.gradle to your installed sdk version.
Otherwise you can just reinstall what ever sdk you were using.
In Android Studio 3.2.1 go to File -> Project Structure -> SDK Location and check in the check box "Use embedded JDK (recommended)".
So i'm trying to use Android Studio 2.2 preview-1 in Ubuntu 14.04 LTS.
I'm using gradle-2.10 and gradle-plugin 2.2.0-alpha1 along with openJDK-8.
compileSdkVersion 23
buildToolsVersion "23.0.3"
First the studio.sh didn't run and i found the solution to change #!/bin/sh to #!/bin/bash. Voila --it starts properly.
But in build.gradle files, warning is shown--
'dependencies' cannot be applied to '(groovy.lang.Closure)'
and its not finding imported class from library project(includes a jar only).
Please someone help me out.
The only fix that I found for this is, every time I open a project, I go to Settings>Build, Execution, Deployment>Gradle, change to "use local gradle distribution", click apply then click "use default gradle wrapper" and ok.
This should fix, but its quite annoying to do this everytime.
It Looks like a problem of version 2.10 of the wrapper version on gradle.
After reading around people's workaround like
"invalidate cache and restart"
delete .gradle file in the project and re-open it
etc etc
I just try for fun to install a standalone version of gradle since I'd always used only the wrapper version that cames with android studio.
And with it there is any error and any warning.
For anyone who wanna try (I'm a mac's user):
install gradle (by homebrew is fine and pretty easy) brew install gradle
tell to AS to use that one instead the wrapper version preference -> build, Execution, Deveployment -> Gradle -> use local gradle distribution
if you install it by homebrew like me the correct path will be: /usr/local/Cellar/gradle/x.yy/libexec
where x.yy it suppose to be 2.11 (that is the last version provide by brew even if the lastest version released is 2.13)
I've realised just now that the steps above doens't fix the definitly. Each time you re-open the project the problem came again and again.
It's annoying but changing betwen use of "wrapper"/"regular gradle" take the warning away.
But this means also that isn't a problem o the gradle as I'd assumed at the beginning.
...let's wait a permanent fix ^^
This issue is fixed in Android Studio 2.2 preview 2 (download from this page).
Disabled a couple of Groovy inspections that reported incorrect errors in build.gradle files
From the changelog.
Working on Linux.
Android Studio 1.4 told me that 1.5 is available in the stable channel;
I upgraded.
Afterward, 1.5 seems to be "looking" for Gradle 2.4; yet 2.8 seems to be what's actually installed.
More details:
After the upgrade, the Gradle sync failed on the project I opened.
Error message:
.../android-studio/gradle/gradle-2.4/lib/plugins/gradle-diagnostics-2.4.jar (No such file or directory)
But the version specific sub-directory within the gradle directory is gradle-2.8
The update procedure itself did not complain about any issues.
The update was done without any open projects; update was done from the main Studio panel.
After the update of Studio itself, via "Configure" from main panel went to "SDK Manager", then updated to newest compatible SDK.
Has anyone else had a similar problem?
Yes, there was a problem in this update.
Open file gradle-wrapper.properties in your project using Android view:
Just change the version 2.4 to 2.8:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Restart Android Studio.
Resolved - it seems some of the Gradle components were on the classpath for the JVM which studio itself uses; somehow the JVM didn't exit when Studio was to have re-started after the update. Once I bought that down and restarted Studio, the JVM and all, Studio 1.5 seems to be working just fine so far.
Sorry for the interruption to your regularly scheduled development!
There is definitely some issue with the upgrade as I also faced the same problem.
Although restarting the system (Mac) fixed it.