首页 文章

如何使用Charles Proxy设置Android Lollipop模拟器?

提问于
浏览
20

我一直在关注其他问题的说明,例如How to configure SSL certificates with Charles Web Proxy and the latest Android Emulator on Windows?(我在MAC上)和SSL Proxy/Charles and Android trouble,我可以使用Charles Proxy分析Android模拟器的数据包一直到Kitkat .

现在我'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'的浏览器,它给出以下错误:
enter image description here

为了启用数据包嗅探功能,Mac OS X上的Android Lollipop仿真器是否需要特殊步骤?

提前致谢!

5 回答

  • 29

    我有同样的,最后找到出路:按照你提到的链接中的说明:How to configure SSL certificates with Charles Web Proxy and the latest Android Emulator on Windows?

    然后从查尔斯进入“代理”菜单并启用“Mac OS X代理” . 比突然的东西来了 . 即使在我关闭'Mac OS X代理'之后......

    ps:通过模拟器上的移动设置设置代理不起作用;代理设置必须通过命令行完成(sdk / tools中的模拟器命令,应该运行如下: ./emulator -avd Nexus_4_API_21 -http-proxy http://<your-ip-as-in-charles-help-menu>:8888 ) . 我've also tried some proxy-apps like the proximator without any succes. Also I'已经有问题,并重新启动查尔斯修复它 .

  • 8

    如果你不想使用命令行,你可以从模拟器执行此操作,它需要更多的设置,但工作得很好:

    • 打开设置>更多>蜂窝网络>接入点名称

    enter image description here

    • 选择主APN并输入代理为10.0.2.2:8888(指向您的计算机localhost)如果您使用实际设备或在本地设备服务器场上,则可以在网络上使用其他IP .

    enter image description here

    • 访问Chrome上的charlesproxy.com/getssl

    enter image description here

    • 将下载SSL证书

    enter image description here

    • 打开时会要求您设置一个引脚或确认它是否已经设置好

    • 为证书命名

    enter image description here

    • 享受代理(您必须在Charles上为您的域启用SSL代理才能查看请求)

    注意:我已经使用API 24仿真器对其进行了测试,但似乎可以正常工作,但它应该适用于其他版本 .

    注意2:从Android Studio 3.0开始,在大多数情况下使用API> 21时将不再需要Charles,因为它将会出现:https://developer.android.com/studio/profile/network-profiler.html

  • 7

    在Android模拟器上进行调试时,在Mac上可能会非常单调乏味 .

    按照步骤:

    1)打开终端并转到SDK路径中的 tools 文件夹 .
    2)在终端上拖放名为 emulator 的文件(这样做会为您提供可执行文件的路径) .
    您的模拟器现在应该读取这样的路径

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

    这里xxxx是您可以在Charles Help菜单中找到的IP地址 .
    3)并执行此操作 .

    瞧!您的模拟器现在将以代理网络模式启动 .

  • 2

    现在Android模拟器中有一个设置
    enter image description here

  • 16
    /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
    

    这应该适用于大多数mac .

相关问题