2013年1月16日水曜日

Proxy with Android Emulator

There are plenty of tutorials out there for installing and running an Android x86 emulator on VirtualBox in Windows (best one I found was herehttp://brunocosta.com/blog/pt/2011/11/02/speeding-up-android-development-with-android-x86-and-virtualbox/). Doing this gives you a much more responsive Android emulator than the one you get with Eclipse. But it's also a bit of a pain to set up.
The thing that had me stumped for a while was how I set up the proxy settings so that the browser could access the Internet. Android (v2.3 at least) doesn't have the option to set proxy settings like Windows does, you have to set it in the Linux command prompt. Do ALT-F1 in Android and in the command prompt type
setprop net.gprs.http-proxy http://1.2.3.4:8080
and substitute the correct IP address and port for your proxy.
That should be all you need to do – fire up the browser and see if you can hit Google.
 
Introduction
config networking via console
Commands
IP
ifconfig eth0 yourip netmask yourip's mask
ifconfig eth0 192.168.1.10 netmask 255.255.255.0
not ipconfig!!!
Gateway
route add default gw yourgateway dev eth0
route add default gw 192.168.1.1 dev eth0
DNS
setprop net.eth0.dns1 yourDNS
setprop net.eth0.dns1 208.67.222.222
Proxy Server
Sorry, I find a way to config proxy http://www.cnblogs.com/DesignPatterns/archive/2008/10/10/1307898.html.
But it only be in effect when reboot machine. LiveAndroid save data in memory, after reboot, all
go back to initial setting. We'll change it soon.
 
 
Android proxy setting
1. Launch adb shell from your-android-folder\tools. [adb shell]
2. Find db file. Normally - /data/data/com.android.providers.settings/databases/settings.db
3. Launch sqlite. [sqlite3 /data/data/com.android.providers.settings/databases/settings.db]
4. Check the databases and tables
Note: the setting of proxy should be inserted into table system
5. Insert proxy setting
6. Check the setting with "select * from system;"
This line - 99|http_proxy|your-proxy:proxy-port - is inserted.
7. Launch browser from emulator and access Internet behind proxy.
 
 
 

0 件のコメント:

コメントを投稿