How to setup Android Lollipop emulator with Charles Proxy?

23,003

Solution 1

I had the same, and finally find a way out: Follow the instruction in the link you mentioned: How to configure SSL certificates with Charles Web Proxy and the latest Android Emulator on Windows?

Then from charles I went into the 'Proxy' menu and enabled 'Mac OS X proxy'. Than suddenly stuff came through. Even after I switched off the 'Mac OS X proxy'...

ps: setting the proxy through the mobile settings on the emulator did not work; proxy setting has to be done through the command-line (The emulator command in in the sdk/tools and should be run something like : ./emulator -avd Nexus_4_API_21 -http-proxy http://<your-ip-as-in-charles-help-menu>:8888). I've also tried some proxy-apps like the proximator without any succes. Also I've have problems and restarting charles fixed it.

Solution 2

If you don't want to faff around with command line you can do this from the emulator, it requires a bit more setup but works nicely:

  1. Open Settings > More > Cellular Networks > Access Point Names

enter image description here

  1. Select the main APN and enter the proxy as 10.0.2.2:8888 (Points to your machine localhost) You can use another IP on the network if you are doing it with an actual device or it's on a local device farm.

enter image description here

  1. Go to charlesproxy.com/getssl on Chrome

enter image description here

  1. The SSL certificate will download

enter image description here

  1. When opening it will ask you to set up a pin or confirm it if you already have it set up

  2. Name the certificate

enter image description here

  1. Enjoy proxying (you have to enable SSL proxying for your domain on Charles in order to see the requests)

Note: I've tested this with an API 24 emulator and seems to work, however it should work with other versions.

Note 2: As of Android Studio 3.0 Charles will be no longer needed when using API > 21 for the most part since this is coming: https://developer.android.com/studio/profile/network-profiler.html

Solution 3

Now there is a setting in Android emulator enter image description here

Solution 4

it might be slighly tedious on Mac while debugging on Android emulator.

Follow the steps:

1) Open terminal and go to tools folder in SDK path.
2) Drag and drop a file named emulator on the terminal (doing so gives you the path of the executable file).
Your emulator should now read the path like this

/Users/your_pc_name/android_sdk/tools/emulator -avd Nexus_6P_API_23 -http-proxy http://x.x.x.x:8888

here xxxx is the IP address that you can find in Charles Help menu.
3) and execute this.

Voila! Your emulator will now start in proxy networking mode.

Solution 5

/Users/`whoami`/Library/Android/sdk/tools/emulator -avd `android list avd | grep Name -m 1 | cut -c 10-99` -http-proxy `ipconfig getifaddr en0`:8888

This should work in most macs.

Share:
23,003

Related videos on Youtube

Some Noob Student
Author by

Some Noob Student

Just Some Noob Student. ( ̄(工) ̄) I ask questions that are dumb and can't distinguish a good answer. ╮(╯▽╰)╭ So please forgive me if I didn't choose your answer as the best answer. o(〒﹏〒)o But I'll make it up to you with upvotes. ‧★,:*:‧\ ( ̄▽ ̄) /‧:‧°★

Updated on September 09, 2020

Comments

  • Some Noob Student
    Some Noob Student over 3 years

    I've been following instructions from other questions such as How to configure SSL certificates with Charles Web Proxy and the latest Android Emulator on Windows? (I'm on a MAC though) and SSL Proxy/Charles and Android trouble and I'm able to use Charles Proxy to analyze the packets of Android emulators all the way up to Kitkat.

    Now I'm trying to do the same for Lollipop emulators. However, when I repeated the same steps I used to successfully setup the Kitkat emulators, Charles show nothing! When I try to connect to the web using the emulator's browser, it gives the following error: enter image description here

    Are there any special steps required for the Android Lollipop emulator on Mac OS X in order to enable packet sniffng?

    Thanks in advance!

  • Chris Gunawardena
    Chris Gunawardena about 7 years
    For me it ended up being ` /Users/chris/Library/Android/sdk/tools/emulator -avd Nexus_5_API_22 -http-proxy 192.168.0.4:8888`
  • TTransmit
    TTransmit almost 7 years
    This works for me once I navigate to charlesproxy.com/getssl
  • Gak2
    Gak2 over 6 years
    The network calls from the emulator show up on charles as raw ip addresses. Is there any way to make them show as their domain names?
  • Chris Gunawardena
    Chris Gunawardena over 6 years
    @Gak2 Restarting charles and/or the sim sometimes fixes this issue for me.
  • Alex Sorokoletov
    Alex Sorokoletov over 6 years
    Does not work with Charles 4.2.1 (latest) and Android Emulator v27 with Nougat 7 running inside. Though I used similar IP to connect proxy to Genymotion (10.0.3.2). Maybe older emulators had it working
  • Curious96
    Curious96 over 4 years
    @Gak2 Refer the blog :) medium.com/@daptronic/…
  • Dmitriy Pavlukhin
    Dmitriy Pavlukhin almost 4 years
    At first it didn't work, but after restarting connection(airplane mode off -> on), certificate finally downloaded