How do I add -http-proxy to an android emulator launch from Android Studio 2.0

后端 未结 3 941
梦谈多话
梦谈多话 2021-01-02 23:27

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

I use a hosts file locally on my laptop to map an url to the machine and apparently the andro

3条回答
  •  佛祖请我去吃肉
    2021-01-03 00:17

    Run emulator from command line

    emulator -avd  -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.

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

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

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

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

    4. 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)

提交回复
热议问题