如何将命令行选项传递给Android Studio中的模拟器? [英] How to pass command line options to the emulator in Android Studio?

查看:80
本文介绍了如何将命令行选项传递给Android Studio中的模拟器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Android Studio 2.1.3. 当我运行Android应用程序时,我选择了一个AVD,我可以在哪里传递诸如-http-proxy之类的命令行选项?我什至找不到运行配置中的方法.

I use Android Studio 2.1.3. When I run an Android app I pick an AVD, where can I pass command line options such as -http-proxy? I don't even find a way in the run configuration.

推荐答案

我发现了一个骇人的解决方案,可以向Android Studio AVD添加参数.

I found a hacky solution to add parameters to the Android Studio AVD.

默认情况下,Android Studio使用二进制文件$ANDROID_SDK/emulator/emulator.在我的情况下,MacOS中的路径为/Users/martin/Library/Android/sdk/emulator/emulator.我所做的是:

Android Studio by default uses the binary $ANDROID_SDK/emulator/emulator. In my case the path in MacOS is /Users/martin/Library/Android/sdk/emulator/emulator. What I did is:

  1. 将二进制文件重命名为emulator-original
  2. 创建名称为emulator的bash脚本,其中包含:

  1. Rename the binary to emulator-original
  2. Create a bash script with the name emulator that contains:

#!/bin/bash /Users/<YOUR_USERNAME>/Library/Android/sdk/emulator/emulator-original <PARAMS> $@

#!/bin/bash /Users/<YOUR_USERNAME>/Library/Android/sdk/emulator/emulator-original <PARAMS> $@

使用chmod +x emulator

现在Android Studio运行我的脚本,而不是运行二进制文件

Now Android Studio runs my script instead of running the binary

这篇关于如何将命令行选项传递给Android Studio中的模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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