Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android emulator proxy setting

I am trying to set up a network proxy to view emulator traffic.

Now if I make a change in network settings of emulator ( 10.0.2.2:< port >, things work fine. But if I try to set the proxy through command line using emulator -avd myAvd -http-proxy localhost:< port > , SSL traffic does not go through and I get time out errors.

Anyone has been able to get this working ?

Thanks

like image 220
Rndm Avatar asked Feb 19 '16 10:02

Rndm


People also ask

How do I change proxy settings on emulator?

With the emulator open, click More , and then click Settings and Proxy. From here, you can define your own HTTP proxy settings. The -http-proxy option forces the emulator to use the specified HTTP/HTTPS proxy for all outgoing TCP connections.


2 Answers

Not sure which emulator you are using, but there is an issue with new Android emulator announced with Android Studio 2 - Bug Tracker

To get a workaround, I had to do the following using the new emulator set to API 23:

  1. Pass -http-proxy http://192.168.x.x:yyyy as a flag when you are launching the emulator. For details how to do this, see here.
  2. Configure the Access Point settings for the proxy within the emulator. To do this, you go to settings->more->cellular network->access point names and edit the existing Access Point.
  3. Finally, there is a setting in Developer Settings for configuring the device to use the legacy DHCP client instead of the new one. This must be configured to use the legacy one.
  4. Toggle Airplane mode on and off.

Access point settings for proxy Developer settings for DHCP client

like image 88
Craig Russell Avatar answered Sep 26 '22 05:09

Craig Russell


Check out comment #6 on https://code.google.com/p/android/issues/detail?id=201402#c6. If you use your computers LAN IP setting the proxy works using the -http-proxy command line switch and no other workarounds are necessary.

For example:

$ emulator -avd Nexus_5X_API_23 -http-proxy http://10.102.80.149:8888 
like image 21
Fabian Frank Avatar answered Sep 23 '22 05:09

Fabian Frank