android - 如何在用于启动 Android 模拟器的 AVD 管理器中获取等效命令行
问题描述
我认为 AVD 管理器实际上是在后台调用模拟器CLI 来启动模拟器。有没有办法查看调用的实际命令(如详细打印输出)?显然,人们总是可以相应地构造命令行参数,这个问题只是要求一种简单的方法来使用 AVD 管理器作为 GUI 生成命令。
解决方案
在运行它之前以某种方式运行set -ex
,以获得详细的输出。曾经写过一个包装模拟器的脚本。一般的名称AVD
足以运行它;这是我用于运行测试的脚本:
#!/bin/bash
# it starts the Nexus 7 emulator.
# export ANDROID_SERIAL=emulator-5554
PROJECT=/some/project
AVD=Nexus_7_API_22
/home/google/android-sdk/emulator/emulator \
-avd $AVD \
-gpu host \
-use-system-libs \
-no-boot-anim \
-verbose &
EMULATOR_PID=$!
adb wait-for-device
# wait for Android to finish booting
A=$(adb shell getprop sys.boot_completed | tr -d '\r')
while [ "$A" != "1" ]; do
sleep 2
A=$(adb shell getprop sys.boot_completed | tr -d '\r')
done
printf "emulator: boot completed."
# unlock the Lock Screen
# adb shell input keyevent 82
sleep 10
cd $PROJECT
# clear and capture logcat
adb logcat -c
adb logcat > ./results/logcat.log &
LOGCAT_PID=$!
# run connected tests
./gradlew mobile:connectedDebugAndroidTest -i
# stop the background processes
kill $LOGCAT_PID
kill $EMULATOR_PID
推荐阅读
- python - 安装scrapy包时如何解决此错误?
- javascript - 在文件输入更改时多次调用处理程序
- android - Android Kotlin 服务问题
- c - 使用ffmpeg的dash muxer时如何设置`seg_duration`的小数值?
- javascript - onClick 没有在 React 中正确触发函数
- laravel-5 - 在 Eloquent 查询或 Yarja 数据表中格式化数字
- docker - 为phoenix映射hbase端口
- angular - 移动键盘可以在 Ionic 应用程序中始终打开吗?
- python - 使用 OpenCV Python 和 Tesseract 从图像中读取车牌
- javascript - 开玩笑 - 将测试分开到另一个文件中