Wednesday, October 28, 2009

Workaround on installing Android SDK 2.0 behind proxy requiring authentication

This morning I tried to install Android SDK 2.0 on my Ubuntu desktop. I downloaded the package with my browser without any problem. Extract it and then run tools/android to download the packages. Realising that my desktop requires a proxy which requires authentication to get to the Net, I went to the Settings panel of the Android SDK and AVD. There are only proxy host and port entries, no username and password entries. I was hoping that the software is smart enough to prompt for username and password later. However, I was wrong. It did not prompt me any authentication form whatsoever. Bummer...... Then I got an idea. I remember few months ago when I set up a forwarding only proxy to act as a child of a parent proxy. I thought if I could get this child proxy to authenticate to the parent proxy and forward all request to the parent proxy, the user won't need to authenticate at all. Hmmm.... Looking at the manual of squid http proxy, I saw cache_peer option which enable child proxy to login to the parent proxy by specifying login=username:password. Yummy.... So, I fired up the trusty apt-get to pull and install squid from my local repository.
$ sudo apt-get install squid
$ sudo vi /etc/squid/squid.conf
Then I added the following setting:
cache_peer parent_proxy.company.domain parent 8080 0 no-query default login=username:password
never_direct allow all
Then I restart squid
$ sudo /etc/init.d/squid stop
$ sudo /etc/init.d/squid start
Then I pointed the Android SDK and AVD to use 127.0.0.1 and port 3128. I also set the software to force downloading using http even if the URL is in https. Finger cross and I tick the site and click Refresh. Viola... it works. It is downloading as I write this blog entries.

19 comments:

Anonymous said...

Hi, i read the snmp code you post the last year, and i'm a student and i'm studying in this arguments snmp, i want know if you can give me the rest of the code because you sad "I don't know how to attach the code to this post..:("...I would really help :(

thank you!

Unknown said...

Hi, Please see this post

Mathieu said...

You're a genius Joko !! Thanx for the tip !

Anonymous said...

Do you have also a similar solution (proxy server application) for Windows ?

Anonymous said...

do you have a similar solution (proxy server application) for Windows ?

Unknown said...

You can use Windows version of Squid. The configuration is similar.

Anonymous said...

Hello

thanks for the share
It was helpfull

Regards

Unknown said...
This comment has been removed by the author.
Unknown said...

do you have any tutorial about squid??
i have tried this tutorial, here is the example :
cache_peer myproxy parent myport 0 no-query default login=myUser:myPasswd never_direct allow all

but i can not start squid :
root@ubuntu:~# /etc/init.d/squid restart
bash: /etc/init.d/squid: No such file or directory

I already install with :
apt-get install squid

i dont know how fix this, i am new in linux, but i'll learn it

Unknown said...

You may try the following command as super user.

# start squid

Some newer distributions are using upstart instead of Sys-V init. Btw, could you please inform me what distribution you are currently using? because they have different ways of doing things.

Unknown said...

thanks a lot sir :D, now i can start learn android more :D

Cyrilleg said...

Thank's a lot ! You save me ;)

chika said...
This comment has been removed by the author.
chika said...

saran ane arahkan proxy server ke ip_address dimana squid terinstall dari pada ke 127.0.0.1[khusus windows os installation]

Unknown said...

@Chika, this is a special case where the proxy requires authentication whereas Android installer does not provides a way to enter username and password (I guess this applies last year, not sure about now). If your proxy does not require authentication then it should be ok to point the proxy directly to the proxy host.

Yudiwbs said...

As alternative, you can use Eclipse (with ADT plugin installed). Start Eclipse, enter proxy username and passwod, click Window --> "Android SDK and AVD Manager".

Unknown said...

thanks a lot :)

Anonymous said...

Very clever "bridge"!

Marcelo Mora said...

Pretty cool solution. Excelent tip.