i have tried it many times but its giving me same error.how to set the proxy so that this error is solved
-
1http://stackoverflow.com/questions/19678137/create-new-project-on-android-error-studio-unknown-host-services-gradle-org – IntelliJ Amiya Nov 12 '15 at 05:12
-
its not working at all i have tried it – avez raj Nov 12 '15 at 05:20
-
1http://stackoverflow.com/questions/18443208/androidstudio-gradle-proxy – IntelliJ Amiya Nov 12 '15 at 05:42
-
1http://stackoverflow.com/questions/31803610/gradle-behind-proxy-in-android-studio-1-3 – IntelliJ Amiya Nov 12 '15 at 05:55
18 Answers
Go to..
Preferences > Settings > Appearance & Behavior > System Settings > HTTP Proxy Enable following option Auto-detect proxy settings
and press Check connection
button for test

- 3,384
- 5
- 40
- 64

- 1,263
- 1
- 12
- 6
In my case issue occurred after following:
I selected proxy settings from Android Studio settings when I was working in a network behind a proxy. When I disconnected from that network and connected to home network which doesn't have a proxy, I removed the proxy settings from Android Studio, but gradle seemed to take the old proxy settings.
The problem was that gradle had also saved the proxy settings in following file when I set proxy settings in Android Studio, but it hasn't got removed when I removed proxy settings from Android Studio.
%HOME%\.gradle\gradle.properties
When I removed the proxy settings from this file, gradle sync worked again.

- 22,324
- 22
- 103
- 179
Update your project level build.gradle to latest version - it works for me
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'

- 27,060
- 21
- 118
- 148

- 16,071
- 12
- 120
- 159
-
For cases when your issue is clearly not due to some proxy-related stuff (e.g. you have never been working behind proxy with current AS setup) this is the best answer - it allows AS to invalidate that very same cache that is causing the issue and not much more. Invalidate and restart will take like forever, while this solution can take from 5 seconds to couple of minutes (depending on extensiveness of your gradle build setup). If you already are using the latest AGP version - just jerk it to some other (older) and then back. – Den Drobiazko Jul 25 '23 at 15:20
I had the same problem. What worked for me was:
Go to File>Invalidate caches/restart>Invalidate and restart.
Hope it works for you too.
If that doesn't work, give your system access to internet and click on Help>Check for Updates. And update android studio to latest versions. All gradle along with plugins will be updated and i guess it should resolve the issue.

- 330
- 2
- 10
make sure that you disable the proxy setting. settting > apperance and behaviour > Http Proxy > and select no proxy check box and check the connection after you select no proxy or auto detect proxy setting > the apply ok

- 51
- 1
-
For anyone with no proxy, this answer plus the Invalidate Caches/Restart... should do it. – rwst Feb 20 '22 at 15:58
Check your internet connection is stable or not. May be this will work with you

- 1,657
- 19
- 23
For some reason, using a shared machine, I couldn`t figure out where this proxy properties is comming from.
So a workaround to fix this is add in you project gradle.properties the following (empty properties). So It will override top hierarchy configuration:
systemProp.http.proxyPort=
systemProp.http.proxyUser=
systemProp.http.proxyPassword=
systemProp.https.proxyPassword=
systemProp.https.proxyHost=
systemProp.http.proxyHost=
systemProp.https.proxyPort=
systemProp.https.proxyUser=

- 205
- 2
- 10
Everyone: I Solved the problem like this. In Android Studio go to File menu and select the Invalidate Caches/Restart... I hope it will work for you. Thanks

- 357
- 4
- 9
Android Plugin for Gradle HTTP proxy settings
For application-specific HTTP proxy settings, set the proxy settings in the build.gradle file as required for each application module.
apply plugin: 'com.android.application'
android {
...
defaultConfig {
...
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain
}
...
}
For project-wide HTTP proxy settings, set the proxy settings in the gradle/gradle.properties file.
# Project-wide Gradle settings.
...
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=443
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.auth.ntlm.domain=domain
...
Please read Official Document Configuration

- 74,896
- 15
- 165
- 198
Download a recent gradle release from gradle.org/releases Unzip the file and copy the gradle folder e.g. gradle 4.0 into C -- program files -- android -- android studio -- gradle. On your android studio goto file -- settings -- Build, Execution, Deployment --Build Tools -- Gradle and choose Use local gradle distribution, in the gradle home locate your gradle folder and click apply. Then click okay. This solved the problem for me. Your android studio might require a more recent gradle release, make sure you download a gradle that is compatible with your studio or latest releases.

- 923
- 11
- 9
Go To: File --> Setting --> Build, Execution, Deployment --> Gradle, then tick the use local Gradle distribution, then set Gradle home by giving path to Gradle. Tick offline work.
Like so:

- 2,478
- 7
- 23
- 35

- 21
- 5
If you are using an http proxy server, revise the following proxy settings in "gradle.properties" file in your project's root folder. If not using proxy server, just delete those entries.
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=UserName
systemProp.http.proxyPassword=Passw0rd
systemProp.https.proxyPassword=Passw0rd
systemProp.https.proxyHost=proxy.abc.com
systemProp.http.proxyHost=proxy.abc.com
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=UserName

- 370
- 4
- 3
The problem is you are not able to download gradle from the host specified in gradle/wrapper/gradle-wrapper.properties
In my case this happened after I refactored the code using Idea. To get this working: 1. Be sure you can download the zip file at URL in the file mentioned above 2. If you can you may wanna check your proxy configuration or env vars

- 1,129
- 8
- 7
Alright, I also had this error and it persist for serveral hours trying the solutions provided on stackoverflow but couldn't resolve the problem.I realised that I had a network proxy configuration connected to an ethernet and i was currently connnected over network tethering on my phone. I disabled the auto detect proxy settings from my network setting on windows and deleting the IP Address and Port number for manual proxy setup and it worked!

- 1
- 1
for me changing ext.kotlin_version in the build.gradle worked.
replace this
ext.kotlin_version = "1.5.20"
with this
ext.kotlin_version = "1.5.0"

- 439
- 3
- 9
I encountered the same issue, while trying to clone some projects from GitHub. After spending few hours I found that the dependencies which are available have https
in their url while Android Studio somehow is only using http
to download those dependencies and therefore shows this error.
Based on @vahid's answer you can go to
File -> Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy and Select "Auto Detect Proxy Settings" -> Then Check the "Automatic proxy configuration URL" checkbox and now paste the url that Android Studio IDE is showing error along with "https://" in the beginning.
For example we have error getting dependencies for this services.gradle.org
so we will paste https://services.gradle.org
and click OK
.
This will download that dependency and you might have few more such errors in IDE after that for other URL's so you just have to follow the same process and just add https://
or http://
.
Meanwhile you can also press on Check Connection with the your url and check it with either https:// or http:// and press OK
to see if it's working.
P.S -> I am sure this is just a workaround and we can do something better to solve it (maybe changing something in gradle settings). I will try to update it if I find something, meanwhile feel free to edit it if you get earlier.

- 878
- 3
- 8
- 26
For me this solved the issue: File > Invalidate Caches > Invalidate and Restart

- 17
- 1
-
This is the same solution as in [this other answer](https://stackoverflow.com/a/61079503/2227743). – Eric Aya Nov 28 '22 at 23:05