如何在 Windows 上使用最新的 Android Emulator 配置像 Fiddler2 或 Charles Web Proxy 这样的 HTTP 代理?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3794998/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to configure an HTTP Proxy like Fiddler2 or Charles Web Proxy with the latest Android Emulator on Windows?
提问by Matt W
I'm at complete odds over configuring a proxy to inspect the HTTP(S) traffic for the app I'm developing. I've tried running Fiddler2 and Charles Web Proxy, both run on 127.0.0.1:888, and starting up the Android emulator with the parameter:
我完全不同意配置代理来检查我正在开发的应用程序的 HTTP(S) 流量。我试过运行 Fiddler2 和 Charles Web Proxy,它们都在 127.0.0.1:888 上运行,并使用以下参数启动 Android 模拟器:
-http-proxy http://127.0.0.1:8888
-http-proxy http://127.0.0.1:8888
To test it out I open the Android browser. I see in Fiddler2 that the request is routed through the proxy. However, only RARELY does the request receive a successful response. In most, and when I say most I mean 99% of the time, the request is retried and fails again with the Android browser telling me "The server failed to communicate".
为了测试它,我打开了 Android 浏览器。我在 Fiddler2 中看到请求是通过代理路由的。但是,请求收到成功响应的情况很少。大多数情况下,当我说最多时,我的意思是 99% 的情况下,请求被重试并再次失败,Android 浏览器告诉我“服务器无法通信”。
Has anyone found a way to configure Fiddler2 or Charles for debugging HTTP(S) traffic through the Android emulator?
有没有人找到一种方法来配置 Fiddler2 或 Charles 以通过 Android 模拟器调试 HTTP(S) 流量?
回答by Christopher Orr
The -http-proxy
emulator option works for me (with a real HTTP proxy behind it), so not sure what the problem with Charles would be.
该-http-proxy
仿真器选项对我的作品(与它背后真正的HTTP代理),所以不知道查尔斯的问题是什么。
An alternative is to capture the network traffic directly, then analyse it afterwards using Wireshark — which can do SSL decryption, if you have the private key.
另一种方法是直接捕获网络流量,然后使用 Wireshark 对其进行分析——如果您有私钥,它可以进行 SSL 解密。
回答by b-ryce
I was able to view the traffic with an HTTP sniffer instead of a proxy. I used HTTPScoop, which is a nice little app.
我能够使用 HTTP 嗅探器而不是代理来查看流量。我使用了 HTTPScoop,这是一个不错的小应用程序。
Also the nice thing about using HTTPScoop is that I can also see traffic on my actual device when I turn on internet sharing and have my phone use the wifi from my mac. So this is a good deal for debugging what happens on the phone itself AND the emulator.
使用 HTTPScoop 的另一个好处是,当我打开互联网共享并让我的手机使用我的 mac 上的 wifi 时,我还可以看到我实际设备上的流量。因此,这对于调试手机本身和模拟器上发生的事情非常有用。
This way it doesn't matter what emulator you use, because the sniffer sees the traffic independent of the emulator, device, compiler settings etc.
这样,您使用什么模拟器都没有关系,因为嗅探器可以独立于模拟器、设备、编译器设置等查看流量。
回答by Robin
I had the same problem with Charles using the Emulator from the Android development tools r12. It should be working when you download r11 and replace the emulator in r12 with the one from r11. The bug is tracked here.
我在使用 Android 开发工具 r12 中的模拟器时遇到了与 Charles 相同的问题。当您下载 r11 并将 r12 中的模拟器替换为 r11 中的模拟器时,它应该可以正常工作。该错误在此处被跟踪。
To get r11 copy the download link from the download pageand change r12 to r11.
要获得 r11,请从下载页面复制下载链接并将 r12 更改为 r11。