could not download httpclient.jar each time I press Try again - android

10:37 PM Gradle sync started
10:37 PM Gradle sync failed: Could not download httpclient.jar
(org.apache.httpcomponents:httpclient:4.5.2): No cached version available
for offline mode
Consult IDE log for more details (Help | Show Log) (642 ms)
How to fix this bug?

Be sure to have configured a remote repository where the component is available. In this case https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient.
Gradle depends on the maven repository. You can define additional repositories either in your gradle script or globally in ${user.home}/.m2/settings.xml.

This error comes when grade version is upgraded (as part of studio upgrade or stand alone). Check latest version and select that as part of settings here.
1- In Android Studio go to File > Settings > Build, Execution, Deployment > Gradle > Use local gradle distribution > then choose the latest version shown or new file (that you might have downloaded and unzip it) from your computer
2- Click Ok
3- Inside "build.gradle(Module:app)" make sure that compileSdkVersion and targetSdkVersion are same
8- Click Sync Now

Related

Android Studio 3.0.1 Error: Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

I've installed Android studio 3.0.1 then tried to build very first app by choosing an empty activity, but I've got this message:
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly
and the error message like this:
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.1.0.
Could not resolve com.android.support:appcompat-v7:26.1.0.
Required by:
project :app
Could not resolve com.android.support:appcompat-v7:26.1.0.
> Could not parse POM https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom
> Already seen doctype.
The first part of log message is like this:
2018-01-03 11:11:12,671 [d thread 8] WARN - ect.sync.idea.ProjectSetUpTask - Already seen doctype.
Consult IDE log for more details (Help | Show Log)
2018-01-03 11:11:12,671 [d thread 8] INFO - e.project.sync.GradleSyncState - Gradle sync failed: Already seen doctype.
I've tried some suggested solutions like changing gradle version, update Kotlin plugin(!) and so, but they didn't work.
Any solution?
This problem occurs when the Build Tools Version is not set for the project.
You just set the build tools version by following this process...
By opening your project structure [File->Project Structure] and selecting the Build Tools Version from app's property tab in Modules section.
This will add build tools version to your gradle file (Module:app) and re-sync the project.
The problem caused by my connection. I needed to set proxy to download some components.
For me the issue was one of the external libraries required SDK 28 but android studio didnt have it so it did not work. I installed SDK 28 and the problem was fixed. I saw the problem in the log file it generated
The error happens under fluctuating network. So at first make sure your connection is stable. Plus, if you are using any VPN check your gradle.properties is configured correctly.
The correct form of VPN connection on gradle.properties is as follows,
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8080
My host connection is 127.0.0.1, and its port is 8080 for both http and https.
Just one more thing, make sure adding https (It is mandatory).
I had the same problem when i was upgrading to android studio 3.1.2 and the problem i was using the previous JDK which i installed before 5 years back.
The steps:-
Go to File -> Project Structures -> SDK Location -> JDK Location -> check the
Option Use embedded JDK (recommended).
I tried all suggestions, only one works for me:
open 'Gradle' tab on right vertical panel
right click on project name
'Refresh Gradle Dependencies' and wait background downloading
right click on project name again
'Reload Gradle Project' and wait refreshing
I was also stuck with the same issue for quite few minutes till I figured out the solution:
So you have to visit Gradle Releases and
there scroll down a little bit and you will find the plugin version and required gradle version. Make sure you use the latest version of both or the ones which are compatible with each other.
For today I am using :
Android Gradle Plugin Version - 7.0.2
Gradle Version - 7.2
You can update it by navigating to:
> File -> Project Structure -> Project
Suddenly My Project showing this Error(Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly). Then i Try to various solutions but not solved.
Then i close the android studio, and open the project location and delete the .idea and .iml file, After deleting this file open the project again on Android studio, after that the project working fine.
I had the same problem, I did download gradle version and used it as a local distribution.
Settings/Build,../Gradle/Use local distribution.
Else you will have to reinstall all the software.
The solution is kinda of very simple.
It's because the "compileSdkVersion" that you are using
in your build.gradle (Module:app) is higher than the SDK installed in your Android studio.
Now, what to do?
Just go on SDK Manager and download an Api Level higher or equal to your "compileSdkVersion" and you're done
Look at the manifest, something may have to go wrong there. In my case I had this label
<uses-sdk android: minSdkVersion = "7" android: targetSdkVersion = "15" />, which was from an example.
Then the error is displayed, and the correspondent is now updated <uses-sdk android: minSdkVersion = "15" android: targetSdkVersion = "27" />
As #oyeraghib said,
Visit this link to check the compatibility of your Android Gradle Plugin in comparison with Gradle itself. I was using an older version of both and updated to version 7 in both.
File -> Project Structure -> Project
It may take a while. Wait for it to load.
change the grade version to the latest one in gradle-wrapper
Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly
Go to gradle scripts -> build gradle(app) -> made following changes:
Finally it works.

Gradle sync failed: Can’t get application id "com.Growl.GrowlHelperApp"

After i upgrade to Android 2.1.3 i got this error:
"1:05:48 PM Gradle sync failed: Can’t get application id "com.Growl.GrowlHelperApp".
Consult IDE log for more details (Help | Show Log)
1:06:42 PM Gradle sync started
1:06:43 PM Gradle sync failed: Can’t get application id "com.Growl.GrowlHelperApp".
Consult IDE log for more details (Help | Show Log)
Have no clue what should i do, any help? thanks!
While I'm not certain if this counts as a canonical "answer", when I installed macOS Sierra, I did get a notification stating that Growl would no longer run. This appears to be supported by Growl's own website as it cannot even be built from source on a modern Xcode or OS X see: http://growl.info/documentation/developer/growl-source-install.php
Unless we can find a way to strip the reliance on Growl out of the Android Studio itself, I don't know that it will be functional on macOS Sierra. It does appear to be baked into several of the jars, though I'm sure someone more resourceful than I will come up with a nifty workaround.
EDIT I was able to build my project by opening the project's build.gradle (Project: project_name_here), and commenting out:
//apply plugin: 'announce'
//apply plugin: 'build-announcements'
From the bottom of the file. This did allow gradle to continue and build my project, which is running just fine.
I downgrade my gradle by choose "Pereference" -> "Build, Execution, Deployment" -> Gradle - > "Use default gradle wrapper(recommended)" then it works.

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

I am getting this kind of error, how to fix it.
Error:Unable to load class 'org.gradle.tooling.internal.protocol.test.InternalTestExecutionConnection'.
Possible causes for this unexpected error Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I updated my Android Studio to 2.3 and it asked me to update my gradle plugin to 3.3 that created issues with my running projects.
I've gone through all the Stack solutions and nothing worked for me except this workaround:
I changed my distribution url in gradle-wrapper.properties with this one.
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
(permanent link list here : https://services.gradle.org/distributions/)
My project is up and running.It just asked me to update to gradle build tools 25.0.0 which I did so. Everything is fine now :)
Go to the project section and select gradle scripts menu.
Under script, menu select gradle -wrapper.properties
Then replace the distributionUrl=https://services.gradle.org/distributions/gradle-2.2-all.zip with "distributionUrl=https://services.gradle.org/distributions/gradle-3.4.1-all.zip"
note: distributions gradle will change depended upon the version of the android studio.
Make sure you have Internet Connection then:
1.For Window Users Go to > C:\Users\username\.gradle\wrapper\dists
2.For Linux users
Go to $HOME/.gradle (~/.gradle) and/or (Under Specific project)
<PROJECT_DIR>/.gradle
3.Delete the gradle file(s) with the problem(i.e the zipped folders with
missing with no its extracted file )
4.Sync the project with gradle files.
Delete corrupt files
This error occurs when Gradle files are not completely downloaded or corrupted by some other reason, so we have to redownload the files.
The easy way is to delete the old files in
C:\Users\username.gradle\wrapper\dists
and rebuild the project, Android Studio will automatically download the new files.
Watch the Tutorial
https://www.youtube.com/watch?v=u92_73vfA8M
or
follow steps :
Go to any browser
type gradle and press enter
you can specify any version you want after the
gradle keyword
i am downloading gradle 3.3
https://services.gradle.org/distributions
click on this link which is in description directly if you want
click on gradle 3.3 all.zip
wait for the download to complete
once the download is complete
extract the file to the location
c://user/your pc name /.gradle/wrapper/dists
wait till extraction it takes 5 mins to complete
Now open your project in android studio
9.go to file > settings >bulid ,exec,deployment > gradle
now change use default gradle to
use local gradle distributn
select the location where you had extracted gradle 3.3.zip
C:\Users\your pc name.gradle\wrapper\dists\gradle-3.3
click on OK
Now build starts again and
you can see now the build is successful and error is resolved
If you manually setup gradle also make sure projects build.gradle verison is compatible with it. See following as an example.
Project's build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
}
Manual gradle setup
A lot of answer to this questions but a few were helping. I want to give accurate and updated answer.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
This error happens when you bad internet connection or you put your computer to sleep while Android Studio is downloading the required dependencies.
How to resolve this issue.
Find out the project's Gradle version. You will find that in gradle-wrapper.properties in distributionUrl my gradle distribution was https\://services.gradle.org/distributions/gradle-6.5-all.zip that means gradle-6.5-all.zip is required to download and right now it is corrupted because of connection timeout. Lets find out this folder and delete this.
Go to $HOME/.gradle folder then to wrapper then to dists then find a folder that matches the gradle version name that required to download. In my case it was gradle-6.5-all.zip select this folder and delete it.
Now sync the project and make sure you have good internet connection and setting that will prevent your system going to sleep while downloading something.
Kindly delele all folders under the in /.graddle/version/
This is how i solved mine. good luck
Maybe you can run ./gradlew build -s in the terminal, the stacktrace would show you where went wrong.
Try the next step to "Refresh" your IDE (android studio)
1. Let Gradle rebuild your auto-genrated files by click Build | Rebuild
2. Also try Choose File | Invalidate Caches/Restart.
I resolved this issue by downloading current version of graddle from link given
download latest version of graddle possibly graddle 3.3
Then in next step i accessed .graddle/wrapper/dists dirctory from home directory on my Mac after showing up hidden system files and deleted previuos version folder residing there.
Now i put that downloaded latest version folder after uncompressing there.
Now restarted Android studio and problem was resolved.
If you are seeing this error in Android Studio 4.1 with Gradle 6.5 then you should move back to
classpath 'com.android.tools.build:gradle:4.0.2'
For some reason
classpath 'com.android.tools.build:gradle:4.2.0'
does not work correctly.
You can try this
first Open your Android Studio > open any project you're doing
click on File > Settings > Build,Execution,Deployment > Gradle
At Project-Level settings , there are 2 option to sync the gradle either usin the default or local.
now change from default to a local gradle distribution > gradle Home
select the path on your computer.
C:\Program Files\Android\Android Studio\gradle\gradle-4.1
click on OK
Now build starts again it should be solved.
Go to "C:\Users\.gradle\caches\". Delete all the files in the folder. Then Sync Gradle and Rebuild the project.
i deleted the gradle folder and then i did rebuild, every thing working fine
If you using Ubuntu, So firstly you have unhide all files from your home directory or where located your android studio folder :
Go to your home directory and unhide all files by using ctrl+h
You found .gradle folder
Inside .gradle -> wrapper
You can found dists folder, So delete this dists folder
Create a New Project than your Gradle file re-downloaded
Congo you successfully build project
check out distributionUrl setting in gradle-wrapper.properties. I changed https to http, then my problem was solved.
In my case,just change http to https in the gradle-wrapper and Sync it.
Just reimport project. :)
I tried cleaning up the cache and refreshing dependencies doesn't work but failed.
Clear .gradle folder and rebuild
Open C:\Users\Username.gradle\wrapper\dists\
Open latest gradle folder, e.g. gradle-4.1-rc-1-all
You will find a random folder named 936kh1brdchce6fvd2c1o8t8x
Download zip file of similar name
eg: https://downloads.gradle.org/distributions/gradle-4.1-rc-1-all.zip
Save it in this folder
Restart Android studio
It will automatically extract the zip folder and Error will clear
Finally solved this problem.
If you just copy new version's files to old folder and override files,you may face the same question as me.
To solve it:
makesure you saved your all settings.
close AS,DELETE ALL files of your mixed version.
extract new version to your empty folder.
It works for me.
For me, i was cloning a project from github which used a version of gradle higher than that which i had installed. I had two choices:
Open gradle.wrapper-properties of a project you have that's building successfully, and copy the line that says distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip. Use this to replace the same value in the project that's failing. That should do the trick.
Your build might still fail if the gradle version used to build the project is higher than that which you just added. For this you should update the gradle version to the latest.
In my case I hade to change from:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
**apply plugin :'com.google.gms.google-services'**
}
to
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'com.google.gms.google-services'
}
search on google "download java 11"
click oracle website download your java to your platform and install it.
go to android studio click CTRL+SHIFT+ALT(Project Structure)
SDK Location Tab Show the path of JDK location which you installed
In your gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
This won't download and always gives 'gradle cache corrupt' error, but a small change makes it work fine
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Now sync the gradle again and it's done.
I will generalize the issue that you might face
Inside module's build.gradle :
Change:
plugins {
[...]
apply plugin:'whatever_you_have'
}
to
plugins {
[...]
id 'whatever_you_have'
}
In other words instead of apply plugin: use id
Unable to find method ''void
com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTest$default(com.android.build.api.extension.AndroidComponentsExtension,
com.android.build.api.extension.VariantSelector,
kotlin.jvm.functions.Function1, int, java.lang.Object)'' 'void
com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTest$default(com.android.build.api.extension.AndroidComponentsExtension,
com.android.build.api.extension.VariantSelector,
kotlin.jvm.functions.Function1, int, java.lang.Object)'
Gradle's dependency cache may be corrupt (this sometimes occurs after
a network connection timeout.)
Re-download dependencies and sync project (requires network) The state
of a Gradle build process (daemon) may be corrupt. Stopping all Gradle
daemons may solve this problem.
Stop Gradle build processes (requires restart) Your project may be
using a third-party plugin which is not compatible with the other
plugins in the project or the version of Gradle requested by the
project.
In the case of corrupt Gradle processes, you can also try closing the
IDE and then killing all Java processes.
It happened to me after upgrading Android Studio to 4.2.0.
Updating the hilt classpath on build.gradle to 2.35 fixed these issues for me.
classpath "com.google.dagger:hilt-android-gradle-plugin:$2.35"
If you have updated your android studio, then go to FILE, Project Structure, Project, then check gradle version. Before that check your gradle version in C:\Program Files\Android\Android Studio\gradle and check the version if it matches then sync again else change the gradle version in android studio and sync again.
I had a similar problem after cloning AnySoftKeyboard and opening it in Android Studio. What worked for me was deleting the AynSoftKeyboard/gradle folder and then cleaning the project via menu item Build > Clean Project.
So try deleting YourProject/gradle folder and clean the project to trigger a Gradle sync.
Hope it works for your case.
download gradle from here for your OS and extract the file and paste the inner folder into installLocation/gradle
than in Android Studio Goto File > Settings > bulid ,exec,deployment > gradle and choose local gradle option and provide the file path of your new downloaded gradle and hit ok it works :)

"Gradle Version 2.10 is required." Error

As I've been using
classpath 'com.android.tools.build:gradle:+'
In the build.gradle file, I got the following error since gradle version 2.10 has been released.
The error is :
Warning:Gradle version 2.10 is required. Current version is 2.8. If
using the gradle wrapper, try editing the distributionUrl in
C:\Users\blahblah\myproject\gradle\wrapper\gradle-wrapper.properties
to gradle-2.10-all.zip
at first it looks easy to solve by the guide, but when I'd done the change, I got the error again.
I'm using Android Studio 2.0 with the latest Android SDK Tools 24.4.1 and Android SDK Build Tools 23.0.2
I've even tried to download Gradle 2.10 and put it manually on android-studio\gradle\ folder, but no luck.
Any help would be appreciated.
You need to change File > Settings > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path
On Mac OS, change the path in Android Studio > Preferences > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home
Or set Use default gradle wrapper and edit Project\gradle\wrapper\gradle-wrapper.properties files field distributionUrl like this
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Open Preference and search for Gradle or Navigate to Builds, Execution, Deployment > Build Tools > Gradle
Then change Project-Level setting to Use default gradle wrapper (recommended)
Or keep local gradle distribution option and set Gradle home to /.../gradle-2.10
Make Sure that Gradle version is already setup to 2.10 in Module Settings
On the Project Window, right click on your project then select Open Module Settings (⌘+↓)
Update
Gradle Version: 3.3
Android Plugin version: 2.3.1
An easier way to accomplish this is to go to:
Open Module Settings (your project) > Project > Gradle version and enter 2.10
Download the latest gradle-3.0-all.zip from
http://gradle.org/gradle-download/
download from Complete Distribution link
open in android studio file ->settings ->gradle
open the path and paste the downloaded zip folder gradle-3.0 in that folder
change your gradle 2.8 to gradle 3.0 in file ->settings ->gradle
Or you can change your gradle wrapper in the project
edit YourProject\gradle\wrapper\gradle-wrapper.properties file and edit the field distributionUrl in to
distributionUrl= https://services.gradle.org/distributions/gradle-3.0-all.zip
For people who are using Ionic/Cordova framework, we need to change the distributionUrl in GradleBuilder.js file to var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.10-all.zip';
The GradleBuilder.js locates at project/platforms/android/cordova/lib/builders/GradleBuilder.js
First Check your Project-level settings at
File > Settings > Build, Executions, Deployment > Build Tools > Gradle
and Select the Option :
Use default gradle wrapper (recommended)
then go to Project's
Gradle > wrapper > gradle-wrapper.properties
and edit version of the distributionUrl
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
And you are done :)
For Android studio v2.1
Follow these easy steps from images.
Go "File" and click "Project structure".
Then select "Project" from left menu and then change "Gradle version" to the version your sdk manager has installed. In my case it is 2.10 so i change version to 2.10 and then click on "Ok". And then android studio automatically do gradle sync again and error was fixed.
Easiest way for me to fix this issue:
close IDE.
delete "gradle" folder
re-open project.
The Android build system uses the Android Plugin for Gradle to support building Android applications with the Gradle build toolkit. The plugin runs independent of Android Studio so the plugin and the Gradle build system can be updated independently of Android Studio.
Use gradle wrapper (recommended) - select this option to use Gradle
wrapper. Using Gradle wrapper lets you get automatic Gradle download
for the build. It also lets you build with the precise Gradle version.
Newer versions of the Gradle plugin may require newer versions of
Studio to enable the new features in the IDE, but the project should
open in older versions of Studio, and build from there (since Gradle
does the build). We will be very careful about this.
Click on Settings -> Build -> Execution -> Deployment ->
Gradle -> Select default gradle wrapper
You can use
classpath 'com.android.tools.build:gradle:2.0.0-alpha3' // or alpha2
Or //classpath 'com.android.tools.build:gradle:2.1.3'
I encountered the same issue before.
In the end, the problem is that you use terminal; it uses system config.
check it, whether you have set
"GRADLE_HOME=.\gradle-2.10"
Hope it helps
If the problem persist, add the following code in the build.gradle of the top project.
buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
...
}
For those who uses ionic, go to [project name]/platforms/android/cordova/lib/builders/GradleBuilder.js on line 164 you will see the following: var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'http\\://services.gradle.org/distributions/gradle-2.13-all.zip';This line is used to create your gradle-wrapper.properties, so any changes to the gradle-wrapper.properties wont matter. All you need to do is change the url to the latest version, sync the gradle and the problem is solved.
Just want to change the gradle version in the Android studio, go to File>settings>project and change the gradle version. After you apply, it will sync the project and you are ready to build.
Important:
If you are getting this when you run:
gradle build
from command line you have to use:
gradlew build
instead so that you will use gradle wrapper to downloaded the appropriate gradle version needed by the app.
When you execute gradle build you are using the global gradle installed on your system.
Go to File -> Settings -> Build, Execution, Deployment -> Gradle -> choose Use default gradle wrapper
for me all previous solutions failed, so i just edited
Project\gradle\wrapper\gradle-wrapper.properties -> field distributionUrl
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
to
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
My problem maybe is different,so I just wanna tell somebody who may have the same problem as me.
I solved this problem by change Terminal path.
when I run gradle clean, the error come cross "Gradle version 2.10 is required. Current version is 2.2.1".
I checked .gradle directory in my project, there are two versions in it: 2.2.1, 2.10.
when I run gradle -v, it shows my current version is 2.2.1.
I change my system environment GRADLE_HOME to 2.10 root directory, then I restart terminal in AS and run 'gradle -v', it still shows the current verision is 2.2.1.
open setting -> terminal change the cmd.exe path to the System32/cmd.exe.
then restart terminal, run gradle clean,everything is fine.
You need to change Prefrences > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path
Or set Use default gradle wrapper and edit Project\gradle\wrapper\gradle-wrapper.properties files field distributionUrl like this
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
I had Android Studio version 1.5.1 installed and was running into this error. I have the following buildscript (which was working on Ubuntu but not Windows):
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
I tried:
gradlew clean
Use default gradle wrapper (recommended)
Use local distribution and linked to downloaded gradle 2.2.1 binary
None of these solutions worked unfortunately. It should be worth noting that upgrading Android Studio from 1.5.1 to 2.1.1 also failed with errors about 2.10 missing so could not be performed.
Solution: What I ended up doing was simply downloaded the latest stable version of Android Studio and installing that instead (2.1.1 at the time). After doing that gradle synced succesfully
What worked for me on Mint 17.03 which is base off Ubuntu 14.04
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle
Reopen Android Studio. Go to Run/Debug Configuration and there should be an icon saying you need to Update gradle. Just click it.
I had the same problem and no answer in stackoverflow helped. But I found the issue in my project. It was because my .gitignore file contained these lines:
# Package Files #
*.jar
*.war
*.ear
and that is why git did not upload the MyProject\gradle\wrapper\gradle-wrapper.jar file to remote. So, I added this line to .gitignore:
!/gradle/wrapper/gradle-wrapper.jar
Make sure you had this line too. At least this solved my problem
In Terminal type gradlew clean. it will automatically download and install gradle version 2.10(ie latest gradle verson available)
Eg : C:\android\workspace\projectname>gradlew clean
this work for me.
create a new project in android studio. Open project setting and copy the local gradle path. now open the project having gradle problem and paste that url and select local path.
click apply problem will get solved.
Some cases it does not work-out because there is no problem in your project gradle or android-studio.
Step 1:
Minimum supported Gradle version is 2.14.1. Current version is 2.11. If using the gradle wrapper, try editing the distributionUrl
Check gradle version in your system gradle -version
Older version upgrade gradle version brew install gradle
Step 2
Go to android-studio-> Preference-> Build,Execution,Deployment-> Gradle
Use default gradle wrapper and un-mark offline work
Step 3
Check distributionUrl in gradle-wrapper.properties
Upgrade if older version.
Clean Project
I had to upgrade my version of Cordova to support the latest version of Gradle. Updating the distributionUrl in GradleBuilder.js didn't work for me.
if your has this error that "supported Gradle version is 2.14.1. Current version is 2.4. ", on terminal. means your should update your gradle.
On Mac OS: you can use brew upgrade gradle
In my case the problem was indeed in the distributionURL in gradle-wrapper.properties file and Android Studio auto-fixed inserting
distributionUrl=https://services.gradle.org/distributions/gradle-4.0-20170417000025+0000-all.zip
But this was a wrong URL. The correct one is
distributionUrl=https://services.gradle.org/distributions-snapshots/gradle-4.0-20170417000025+0000-all.zip
Apparently the url changed in gradle's API but not in Android Studio so fixing it by hand solved the problem for me.
Latest gradle
Download the latest gradle-3.3-all.zip from
http://gradle.org/gradle-download/
1.download from Complete Distribution link
2.open in android studio file ->settings ->gradle
3.open the path and paste the downloaded zip folder gradle-3.3 in that folder
4.change your gradle 2.8 to gradle 3.3 in file ->settings ->gradle
5.Or you can change your gradle wrapper in the project
6.edit YourProject\gradle\wrapper\gradle-wrapper.properties file and edit the field distributionUrl in to
distributionUrl=
https://services.gradle.org/distributions/gradle-3.0-all.zip
shown in android studio's gradle files
File - setting - Build Execution Deployment - Gradle - Select 'Use default gradle wrapper(recommended)'

Android Studio Gradle Download Error

When I load Android Studio, I get an error
Gradle 'HelloWorld' project refresh failed
Error:Could not download artifact 'com.android.tools.build:builder-model:0.12.1:builder- model.jar': No cached version available for offline mode
Not only this but Android Studio takes a long time to load a project; stuck on Gradle Resolve Dependencies.
I am on Windows 8.1 and using JDK 8
How would I fix this?
You probably have Android Studio configured to use Gradle in offline mode, and it's failing because it lacks dependencies that it needs to download. Make sure your computer has internet connectivity, and in Preferences > Gradle > Offline work, make sure that setting is unchecked.
For Android Studio 3.3.2 -
Open File > Settings > Gradle > (unchecked) offline work on Global Gradle Setting.
Make sure that you have internet connection and try to sync your project more (or File > Sync project with gradle files).
the simplest solution is -
click file > project structure > Gradle Setting >
now check if your "Gradle user Home" field is empty if it is . then enter the path of your gradle.
your gradle should be stored in
C > users > .gradle
copy the path and enter it here and now click on gradle build button on top right in your android studio.

Categories

Resources