Bharathi Subramanian

The Social Animal 
« Back to blog

Install Android SDK thru Proxy with Authentication

Today I was trying to download and install additional SDK R5 components from Internet using the Android SDK and AVD Manager tool. Initially, the download was continuously failed, because, my system is behind a Proxy, which need an authentication. Android SDK and AVD Manager does not provide any option in the proxy settings, to include the proxy authentication (user name and password) details.

So I decided to run my own proxy server locally and configure it to talk to the parent (original) proxy server with authentication detail. Initially, I decided NOT to run the heavy weight proxy Squid and selected TinyProxy for this purpose. But TinyProxy not supported the Authentication feature. So finally ended up running Squid proxy with following configurations:

# Listen only local interface
http_port 127.0.0.1:3128

# Parent proxy (192.168.1.253:8080) and Authentication settings
cache_peer 192.168.1.253 parent 8080 0 no-query default login=User:Passwd

# No direct access
never_direct allow all

After restarting the Squid, I changed the proxy settings of Android SDK and AVD Manager to:

Proxy: 127.0.0.1
Port: 3128

After this, restarted it. Now the additional components are successfully downloaded.

Comments (26)

Mar 31, 2010
Victor Bello said...
Where can I get my hands on Squid for Windows?
Apr 01, 2010
Apr 05, 2010
Victor Bello said...
OK, I got it, but after configuring it, I still get Authentication Failed on the android SDK. Any ideas? Maybe post the whole config file for squid?
Apr 06, 2010
From the browser, Is it possible for you to goto Internet using the User:Passwd, which is mentioned in squid conf file.
May 12, 2010
Shane said...
After much messing around, I managed to get this working really easily.
Edit android.bat, and in the call to java.exe, insert the following parameters VM parameters before -jar
-Dhttp.proxyUsername="username" -Dhttp.proxyPassword="password"
Note that there's no space between D and http. You still need to put in the host/port in the settings.
Jun 04, 2010
S. M. Das said...
!!!

Thank you Shane! Turns out, for the Linux SDK, it's the very last line of the "tools/android" that these settings belong in.

It was a super easy thing to patch... I should probably make those two fields available as command-line options to "android" and see if Google is interested in that feature. It is certainly the best way to make the updater useful behind an authenticated web proxy.

Jun 22, 2010
Feliponcho said...
I'm also behind a proxy but we use automatic proxy configuration url. Any idea on how to configure android.bat to use the conf url? thanks!
Jun 22, 2010
rayshi said...
I am also behind the scripted proxy. Does squid handle that kind of proxy?
Jun 22, 2010
Feliponcho said...
Hi, I just moved into Android 2.2 and the problem was solved. Also let me tell you that in my company have 2 proxies and 1 scripted proxy. I tried with one of the proxies and it didn't work and with the other worked perfectly. I would recommend to talk with your tech support and see what options they have for you. BTW according to google support proxy definitively doesnt work in 2.1.
Sep 07, 2010
Android Proxy said...
For non technical people here is a step by step guide on how to set up proxy in Android http://android-proxy.blogspot.com/
Feb 18, 2011
Mayank said...
Shane, can you mail or paste your modified android.bat file here
Feb 22, 2011
shivang said...
im using your freedom for bypassing the proxy and the installation runs fine but it stops at 93%, i dont know if its a problem just on my connection. u can try it to if it works for u all.
Mar 09, 2011
pietro said...
Start Manager and set proxy name and port in "settings" tab.
Don't put "HTTP" before proxy name.

Edit android.bat file and change the lines before SetPath:

rem Finally exec the java program and end here.
call %java_exe% -Dcom.android.sdkmanager.toolsdir="%tools_dir%" -Dcom.android.sdkmanager.workdir=%work_dir% -Dhttp.proxyUsername="DOMAIN\USER" -Dhttp.proxyPassword="PASSWORD" -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*

PIETRO

Mar 25, 2011
Dan said...
I can confirm Pietro's solution worked for me
Apr 06, 2011
Tarantini said...
You can find file: androidtool.cfg on c:\Documents and Settings\YOU USER NAME\.android\
and you add line "http.proxyLogin=USER@PASSWORD" and save the file and try open ANDROID SDK

Taranttini - www.taranttini.com

May 11, 2011
nanda said...
installing a squid was a convenient solution.. thank you.
was struggling a lot with it..
May 18, 2011
sc said...
pietro's solution worked for me as well.
May 29, 2011
zmf said...
Thank you Tarantini
(of course for linux its in ~/.android/androidtool.cfg)
it work :)
Jun 10, 2011
sfg said...
install ccproxy on vmware,set your ip and u r ready 2 go
Jul 16, 2011
Droid said...
Thank you Pietro! Your solution worked flawlessly.
Jul 22, 2011
tushar said...
I tried a lot but can not be able to solve this problem I am in a college where proxy server is running with user name and password authorization pls send me a modified android.bat file at this e-mail address trnkumar32@gmail.com pls sir thanks in advance
Aug 28, 2011
Amit said...
http://allaboutandroid-frombasictoadvance.blogspot.com/ chk out dis ..no need to do all above stuff
Sep 06, 2011
Zsolt said...
Hello. I installed CCProxy on windows, then i was able to setup upper level proxy, and everything works like charm.
Sep 27, 2011
Mario Bedeschi said...
I have the same issue, after install eclipse works just find.... with eclipse you can provide user and pass word for your proxy. Then download ADT Plugin for Eclipse.
Now you are able to work.
Regards
Mario Bedeschi
Oct 07, 2011
Mouad Khateb said...
@ Pietro @Dan @sc @Droid
I am not sure but I think you meant AFTER ":SetPath" because what's before it is not identical with the lines you provided. I assumed it is After, and now the end of my .bat file looks like this (after replacing the original lines that come after SetPath with the ones U suggested):

_________________
:SetPath
rem Finally exec the java program and end here.
call %java_exe% -Dcom.android.sdkmanager.toolsdir="%tools_dir%" -Dcom.android.sdkmanager.workdir=%work_dir% -Dhttp.proxyUsername="XXXXXX" -Dhttp.proxyPassword="XXXXXX" -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*

rem EOF
__________________

Yet this gives me "access is denied".
Questino is, after Dhttp.proxyUsername should I only input the username, or the domain followed by the username? In what format should that be?

Thanx

Mar 01, 2012
Sandino Santos said...
Thanks, thanks, thanks, thanks, and thanks from Brazil

Leave a comment...