简体   繁体   English

Android模拟器代理设置

[英]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. 现在,如果我对模拟器的网络设置进行了更改(10.0.2.2:<port>,那么工作正常。但是如果我尝试使用模拟器-avd myAvd -http-proxy localhost:<port>通过命令行设置代理, SSL流量没有通过,我有时间错误。

Anyone has been able to get this working ? 任何人都可以使这个工作?

Thanks 谢谢

Not sure which emulator you are using, but there is an issue with new Android emulator announced with Android Studio 2 - Bug Tracker 不确定您使用的是哪个模拟器,但Android Studio 2宣布的new Android模拟器存在问题 - Bug Tracker

To get a workaround, I had to do the following using the new emulator set to API 23: 要获得解决方法,我必须使用设置为API 23的new模拟器执行以下操作:

  1. Pass -http-proxy http://192.168.xx:yyyy as a flag when you are launching the emulator. 传递-http-proxy http://192.168.xx:yyyy作为启动模拟器时的标志。 For details how to do this, see here. 有关如何执行此操作的详细信息,请参阅此处
  2. Configure the Access Point settings for the proxy within the emulator. 在模拟器中配置代理的Access Point设置。 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. 最后, Developer Settings有一个设置,用于配置设备以使用旧版DHCP客户端而不是新客户端。 This must be configured to use the legacy one. 必须将其配置为使用旧版本。
  4. Toggle Airplane mode on and off. 打开和关闭Airplane模式。

代理的接入点设置 DHCP客户端的开发人员设置

Check out comment #6 on https://code.google.com/p/android/issues/detail?id=201402#c6 . 查看https://code.google.com/p/android/issues/detail?id=201402#c6上的评论#6。 If you use your computers LAN IP setting the proxy works using the -http-proxy command line switch and no other workarounds are necessary. 如果您使用计算机LAN IP设置代理使用-http-proxy命令行开关工作,则不需要其他解决方法。

For example: 例如:

$ emulator -avd Nexus_5X_API_23 -http-proxy http://10.102.80.149:8888

I've recently had to set up a sniffing environment to debug some Android SSL traffic. 我最近不得不设置一个嗅探环境来调试一些Android SSL流量。

It seems now that you no longer need to set the proxy on the emulator's access point (steps 2-4 on @craig-russell's answer). 现在看来,您不再需要在模拟器的访问点上设置代理(@ craig-russell的答案中的步骤2-4)。 Adding the -http-proxy launch parameter is enough. 添加-http-proxy启动参数就足够了。 Also tried on API levels < 23 and succeeded. 还尝试了API级别<23并成功。

My specs: Android Studio 2.3.1 Windows 10 Android emulator version 25.2.5.0 我的规格:Android Studio 2.3.1 Windows 10 Android模拟器版本25.2.5.0

Full details: http://www.devsbedevin.net/debugging-android-ssl-traffic/ 详细信息: http//www.devsbedevin.net/debugging-android-ssl-traffic/

There's a chance that your proxy server returns some additional HTTP headers in its response to Android emulator's HTTP CONNECT request. 您的代理服务器有可能在其对Android模拟器的HTTP CONNECT请求的响应中返回一些额外的HTTP标头。 If so, you may encountered a known issue which should've been fixed by now, but due to desync between development branches, the fix has never been released. 如果是这样,您可能会遇到一个已知问题 ,现在应该已经解决,但由于开发分支之间的异步,修复程序从未发布过。 Please see my comment for the details. 有关详细信息,请参阅我的评论

To clarify, HTTP requests are unaffected by the issue because they don't rely on connection tunneling (ie HTTP CONNECT), being delivered via HTTP Message Forwarding defined in RFC7230 instead. 为了澄清,HTTP请求不受该问题的影响,因为它们不依赖于连接隧道(即HTTP CONNECT),而是通过RFC7230中定义的HTTP消息转发来提供。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM