Proxy Error when downloading gradle zip during "ionic emulate android"

I’m working with my first app and after getting my system setup (except for this, I guess), I get the following error when I try to launch the app in the android emulator. I’m on Windows 7, on a corporate network, behind a proxy server.

D:\dev\<company>\<project>\App>ionic emulate android
Running command: "D:\Program Files\nodejs\node.exe" D:\dev\<company>\<project>\App\hooks\after_prepare\010_add_platform_class.js D:\dev\<company>\<project>\App
add to body class: platform-android
Running command: cmd "/s /c "D:\dev\<company>\<project>\App\platforms\android\cordova\run.bat --emulator""
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_38
WARNING : no emulator specified, defaulting to x86-5.5.1
Waiting for emulator...
emulator: device fd:872

HAXM is working and emulator runs in fast virt mode
creating window 0 0 578 1026
emulator: emulator window was out of view and was recentered

Booting up emulator (this may take a while).......BOOT COMPLETE
Running: D:\dev\<company>\<project>\App\platforms\android\gradlew cdvBuildDebug -b D:\dev\<company>\<project>\App\platforms\android\build.gradle -PcdvBuildArch=x86 -Dorg.grad

Exception in thread "main" java.lang.RuntimeException: Server returned HTTP response code: 401 for URL:
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(
        at org.gradle.wrapper.Install.createDist(
        at org.gradle.wrapper.WrapperExecutor.execute(
        at org.gradle.wrapper.GradleWrapperMain.main(
Caused by: Server returned HTTP response code: 401 for URL:
        at org.gradle.wrapper.Download.downloadInternal(
        at org.gradle.wrapper.Install$
        at org.gradle.wrapper.Install$
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(
        ... 3 more

                    throw e;
Error code 1 for command: cmd with args: /s /c "D:\dev\<company>\<project>\App\platforms\android\gradlew cdvBuildDebug -b D:\dev\<company>\<project>\App\platforms\android\build.gradle -PcdvBuildArch=x86 -Dorg.gradle.daemon=true"
Error: cmd: Command failed with exit code 1
    at ChildProcess.whenDone (C:\Users\<user>\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
^CTerminate batch job (Y/N)? y

Base don the 401, I assume that Java isn’t getting through our proxy. If that’s the case, is there any way for me to set credentials for this call? I can enter that path in Chrome and download the zip file with no problem so the 401 seems to be on my end and not at

find ‘’ file in ‘.gradle’ folder and add your proxy detail like below then try again. it will solve problem



Thanks! I like this suggestion better than what I ended up doing.

To solve the problem immediately I followed an answer I found on StackOverflow that suggested downloading the file, saving it to the platforms\android path and then updating build.js to point to this path instead of downloading the file from Your solution fixes the root cause, +1!

Mike Devenney

This is because of gradle error Download the file
and extract it in any of directory and set the path by open cmd and enter
setx path (extracted direstory)/bin
after reopen cmd and check whether the gradle is works or not by give
gradle -v
it shows the gradle version output .
Now the error is fixed run
ionic build android

I’m facing the same problem when running “ionic cordova build anroid” command.
Solutions I’ve tried:

  1. Setting http_proxy and https_proxy environment variables.
  2. I could not find anywhere in my project so created one at the base path of the project with the following entries:
    systemProp.http.proxyHost=my_proxy_host (without http)
    systemProp.https.proxyHost=my_proxy_host (without http/https)
  3. I’ve downloaded the (this was the version in my GradleBuilder.js) and placed it in my project and modified GradleBuilder.js accordingly. It fixes this but the command tries to download some *.pom files where it times out.
    Can someone suggest me anything that I can try beyond this.
    P.S: All the above things are working on VM. So I kinda believe it is an issue due to the proxy

Thanks in advance!

is there any one found the solution ?? i am also facing the same issue