如何将-http-proxy添加到从Android Studio 2.0启动的android模拟器中 [英] How do I add -http-proxy to an android emulator launch from Android Studio 2.0

查看:188
本文介绍了如何将-http-proxy添加到从Android Studio 2.0启动的android模拟器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个本地开发Web服务器在我旁边的机器上运行.

I have a local dev web server running on a machine sitting next to me.

我在笔记本电脑上本地使用主机文件将URL映射到计算机,显然android仿真器使用NAT且无法解析该URL.

I use a hosts file locally on my laptop to map an url to the machine and apparently the android emulator uses NAT and can't resolve the url.

我想将仿真器配置为对所有Internet流量都使用Charles Proxy,以便它将通过我的笔记本电脑并提取我的主机文件以进行名称解析.

I wanted to configure the emulator to use Charles Proxy for all Internet traffic so that it will go through my laptop and pick up my hosts file for name resolution.

此处的说明说我需要设置- http-proxy.

The instructions here say I need to set -http-proxy.

如果我从Android Studio 2.0启动怎么办?

How do I do that if I launch from Android Studio 2.0?

推荐答案

从命令行运行模拟器

emulator -avd <avd name> -http-proxy ip:port

emulator -avd Nexus_5_API_23 -http-proxy 127.0.0.1:8888

Windows

%UserProfile%\AppData\Local\Android\sdk\tools\emulator -avd Nexus_5_API_23 -http-proxy 127.0.0.1:8888

顺便说一句 我无法为我做代理.

BTW I wasn't able to make a proxy work for me.

还有其他选择查看Android HTTP连接的最佳方法:

There other alternatives The best way to review Android HTTP connections:

  1. OKHtttp日志拦截器-登录logcat,非常适合改装

  1. OKHtttp Logging Interceptor - logs in logcat, good for Retrofit

Flipper https://fbflipper.com/-不错的用户界面和现代的多平台方法

Flipper https://fbflipper.com/ - nice UI and modern multiplatform approach

Network Profiler-内置到Android Studio中,但我从未使它起作用

Network Profiler - build into Android Studio, but I never made it work

Stetho http://facebook.github.io/stetho -允许显示Google chrome开发人员工具中的所有android设备/模拟器请求/响应(不建议使用,但仍然可以正常使用)

Stetho http://facebook.github.io/stetho - allows to display all android device/emulator requests/responses in Google chrome developer tools (deprecated but still works well)

这篇关于如何将-http-proxy添加到从Android Studio 2.0启动的android模拟器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆