I updated my android studio to the new version 2.3 and was asked to convert my project to match the new formats which I did. I was asked to update the gradle version too and I did. Now one eternity later it's still refreshing my project gradle. I've restarted it several times and I have active internet connection. Any suggestions
This method works for Me :
Change Gradle Home Path as C:\Program Files\Android\Android Studio\gradle\gradle-3.2
To Open Gradle Home Setting :
Settings->Build,Execution,Deployment->Gradle->Gradle Home
It depends sometimes on what are you building. As Hamid said, it´s a must do working Offline, it greatly reduces times, or at least it did not that long ago.
Also checkout that you are not building google APIs that you are not using, be careful with google's play-services or maps, they sometimes take a bunch of time and maybe you are not using them.
If that's an option, install Android Studio in a SSD, don't buy one, but if you have it, consider moving it, it reduced my gradle about 90%.
Also, check this, a bit old, but may help.
Could be caused by Microsoft Defender.
Check if msmpeng.exe is running in task manager
and exclude Android directory.
using default gradle wrapper and disconnecting from my corporate network to a 4G network solved my problem
File> Settings> Build, Execution, Deployment> Gradle> and check the Offline work
If you have an failed for sync gradle. Such as; Gradle sync failed: Minimum supported Gradle version is 3.3. Current version is 3.2.
Download Gradle supported version manually.
Uncheck "Use default gradle wrapper (recommended)"
Check "Use local gradle distribution" and set Gradle home path.
Check offline work.
Updating the gradle path in
File > Settings > Build, Execution, Deployment > Gradle
worked for me. The problem occured after updating Android Studio.
Related
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.
this is my default gradle version.
then this is my config in my project ,like this
however,when i set the gradle version in project structure,like this,my studio show a progress till now.
i don't know whether is my config wrong,or other reason.Can any one tell me how to config the gradle? thanks!
Try to uncheck Offline work on Global Grade settings.
AndroidStudio came with gradle-wrapper AKA ./gradlw so ideally you don't really need to install gradle on the machine.
Check the network settings if it takes too long for gradle to download all the dependencies.
And don't check offline mode :)
While trying to build my Application on Android Studio 2.1 (On Ubuntu 16.04), it gets stuck on the below note:
Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources]
Can anybody please help me out.
Actually it is not stuck. It takes more time to build. I have got almost 3 solutions that can fix the issue.
Solution-1:
Following the steps will make it 10 times faster and reduce build time 90%
First create a file named gradle.properties in the following directory:
/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)
Add this line to the file:
org.gradle.daemon=true
org.gradle.parallel=true
Solution-2:
If Android Studio has a proxy server setting and can't reach the server then it takes a long time to build, probably its trying to reach the proxy server and waiting for a timeout. When I removed the proxy server setting its working fine.
In Android Studio go to File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle
Check the 'Offline work' under 'Global Gradle settings'
It will reduce 90% gradle build time.
Solution-3
If you are using Google Play services, make sure you aren't using this in your Gradle build script:
compile 'com.google.android.gms:play-services:8.3.0'
Only use those Google APIs that your app is really using. If all you are using is Google Maps, you would use this:
com.google.android.gms:play-services-maps:8.3.0
When I did this, my compile time went from over 2 minutes to around 25 seconds. For a list of the Google apis that you can selectively compile against, see:
https://developers.google.com/android/guides/setup
Resource Link:
Android Studio gradle takes too long to build
Discussion about stuck in gradle build
Solution#4:
Arun George has commented the following solution.
the issue was due to certain 32 bit libraries missing. Had to do sudo apt-get install lib32z1. Adding to gradle.properties helped reduce
the build time.
The issue is that the project isn't synced with the gradle files. The resolution I did was go to File > Sync Project with Gradle Files and it was able to sync.
Changing buildToolsVersion was the solution for me.
For my case I had to install gcc-multilib
$ sudo apt-get install gcc-multilib
Check the Gradle Console at the bottom right as it has more output than the Event log.
I have tried all solution. Nothing has worked. So I just restarted my PC and its working fine. You can try it.
You're probably behind the proxy, you might have recently changed your password or something has changed. Go to
/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)
in gradle.properties file, delete/ change proxy settings. They are different to your android studio proxy settings.
Had the same issue, gradle used to take an hour to build. After I deleted proxy settings from gragle.properties file, it now takes couple seconds.
Adding more to #SkyWalker's answer:
Also check if you have the latest version of gradle. Updating gradle plug-in to the latest version could help.
Note: I have a similar setup(Android Studio 2.1 on Ubuntu 16.04), and I had a similar problem. Updating gradle to the latest version solved the problem for me.
Resolution for Gradle stuck using Android Studio version 4.2.2:
When the resources are downloaded successfully the Android Studio should be restarted with "Invalidate cache and restart" and offline Gradle mode should be activated before platform-tools indexing.
May be it's bad way, but start studio with
sudo nice --17 IDE name
seems worked for me
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.
I have just upgraded (i.e., installed a full new version) my Android Studio from 1.5 to 2.0. The upgrade seemed to go smoothly, but I am having trouble with my project when I open it, when Gradle is syncing my project.
After Gradle sync runs for a couple of minutes I get this error:
Failed to sync Gradle project MyProject
Unknown host 'jcenter.bintray.com'. You may need to adjust the proxy settings in Gradle.
Error: Enable Gradle "offline mode' and sync project
Learn about configuring HTTP proxies in Gradle
So, I click on the link that says:
Enable Gradle "offline mode' and sync project
Then Gradle spins for a second or two, and I now have this message:
Failed to sync Gradle project MyProject
Error: No cached version of com.android.tools.build:gradle:1.3.0 available for offline mode.
Disable Gradle 'offline mode' and sync project
So, I click on this link:
Disable Gradle 'offline mode' and sync project
And I am back to my first error again.
The machine I am working on is 100% off line. It does not have, nor will it ever have any kind of network connection whatsoever. I figure I need to disable some kind of check that requires the internet, but I am not sure what. Is this fixable, or do I have to downgrade back to Android Studio 1.5?
UPDATE
I am also getting this error message:
Gradle sync failed: Unknown host 'services.gradle.org'. You may need to adjust the proxy settings in Gradle.
Ok, I fixed my issue so I wanted to post how I did it in case somebody else runs into this situation.
I was googling around and found a statement regarding working offline with Android Studio that read:
You can, however you won't be able to use any Gradle dependency. Gradle search into the repositories for dependencies using internet, so if you're completely unable to work online. Try not to include anything in the Gradle files, if you do, you'll have to sync it and it'll fail. Bascially just don't touch Gradle files and you'll be good to go.
So, I looked at my gradle files, specifically the build.gradle for the Project (not for the Module). Once there, I noticed a line:
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
So, I replaced 1.3.0 with 2.0.0 and the project built just fine.
I hope this helps somebody else in the future. Good luck.
I got same problem when I downloaded "BackboneExampleApp" source code from guithub Click Here For Code. I have done following process by watching settings of my old projects and found these errors. I resolved both errors, run my app and got errors to upgrade project and finally when I updated then no more problems exist. Just see pictures for help.
build.gradle (Project:BackboneExampleApp-master)-->
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
I also come with the same problem in my application. I have Done invalidate caches/restart then the problem is resolved.
I had the same problem as yours. Fortunately, I managed to solve it. You need to go to File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle. You need to change the Gradle Home. Mine was "C:/Program Files/Android/Android Studio/gradle/gradle-2.08" and it said the path is invalid. So, just recheck your path in your file explorer and change it. I changed mine to "C:/Program Files/Android/Android Studio/gradle/gradle-2.10".
I had a similar problem. I was trying to build one of the media samples. I tried to use gradle 2.0.0 as you suggested but it didn't work. Got me on the right track though. gradle 2.1.0, along with deactivating offline mode got it to work.
For me it was a connection issue, that I have checked my connection is working in the same second I have enabled and disabled offline Gradle, then Android Studio download the needed files
NB: My Connection was disconnecting and reconnecting many times, so i figured out that this error was caused by the connection specially it was not the same time it takes when trying to sync my Gradle
For those have issues with error message: Learn to configure HTTP settings, below is the solution that worked for me. Am using Android studio 2.3.3:
Go to http://developer.android.com/studio/intro/studio-config.html
Step 1: Follow the instructions on: Set up Android studio proxy.
Step 2: Follow the instructions on : Android plugin for gradle HTTP proxy setting. You will see proxy settings under : # project wide gradle settings, copy the code there and paste it into the empty space in gradle properties file which is under the build gradle in Android studio. Make sure you are connected to internet while on this process. Wait until the the error disappears.
Step 3: you may see another message pop up stating: some folders may have been missing syn now. Just click on syn now.
I hope this help, thanks all.
I was fallen the same trouble, you mentioned. But I solved it myself. I connected my pc to the internet and rebulit the project using PROJECT>>REBUILT PROJECT.
Then some downloads could be seen below with the name of jcenter.......
THEN THE PROBLEM SOLVED...😃
Gradle build became successful..
I faced the same issue. Make sure that you have made an entry in path in environment variable for gradle
C:\Program Files\Android\Android Studio\gradle\gradle-3.2\bin
After disable offline mode and setting the path in environment variables, the issue was fixed and Gradle was build cleanly.
It seems there are multiple reasons for this issue. I fixed it by changing the "Gradle version" and "Android plugin version".
It might be helpful to someone. Go to File->Project Structure. Select Project and update your gradle and android plugin versions.
I also came with the same problem in my application..The application Gradle version is 2.3.3 .I just update the Gradle to 3.0.1 .and the problem is solved.
My problem was different from all answers; gradle distribution url was wrong..
It might be the problem that distributionUrl can be wrong in gradle-wrapper.properties file.