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

查看:26
本文介绍了如何将命令行选项传递给 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 添加参数的 hacky 解决方案.

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

创建一个名为 emulator 的 bash 脚本,其中包含:

Create a bash script with the name emulator that contains:

/Users/<YOUR_USERNAME>/Library/Android/sdk/emulator/emulator-original <PARAMS> $@```

  • 使用 chmod +x 模拟器

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

    Now Android Studio runs my script instead of running the binary

    更新:先尝试 Stef 的解决方案,它看起来比这个 hack 更好

    Update: try Stef's solution first, it looks better than this hack

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

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