0%

mac平台配置谷歌GMS测试工具

之前发的在aarch64 Linux上运行amd64架构的应用,本质上是因为我需要一个跑谷歌测试工具的环境,重新读了一下README和启动脚本后发现,这个工具并没有限制一定要运行在Linux系统上,
从启动脚本来看,至少是可以支持Linux和macOS的,并且我在M1 Pro上也确实跑成功了,但在arm64的Ubuntu上却没有,之后如果有空的话再研究看看咋回事

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
checkPath aapt
checkPath adb
checkPath java
# get OS
HOST=`uname`
if [ "$HOST" == "Linux" ]; then
OS="linux-x86"
elif [ "$HOST" == "Darwin" ]; then
OS="darwin-x86"
# Bundled java is for linux so use host JDK on Darwin
JAVA_BINARY=java
else
echo "Unrecognized OS"
exit
fi

要启动测试工具主要有4个检查,一类是检查环境变量,一类是检查系统,环境变量里需要有aapt,adb和java,系统需要时Linux或macOS,我安装的java版本是11.0.18,似乎是同时兼容x86_64和arm64e

1
2
3
4
5
6
7
8
magicdian@MacBook-Pro-14 ~ % file /usr/bin/java
/usr/bin/java: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/java (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/java (for architecture arm64e): Mach-O 64-bit executable arm64e
magicdian@MacBook-Pro-14 ~ % java --version
openjdk 11.0.18 2023-01-17
OpenJDK Runtime Environment Temurin-11.0.18+10 (build 11.0.18+10)
OpenJDK 64-Bit Server VM Temurin-11.0.18+10 (build 11.0.18+10, mixed mode)

adb的话,可以去谷歌官网下载platform-tools,我是通过homebrew来安装的,我记得好像之前的platform-tools只提供了amd64的版本,但现在官网也是universal版本了,所以从官网还是homebrew下都无所谓

然后就需要解决mac平台的aapt了,brew没办法安装,这个aapt是在安卓SDK的build tools目录下的/Users/你的用户名/Library/Android/sdk/build-tools/你的SDK版本/,测试之前用以下命令添加到环境变量就好

1
export PATH="你的aapt路径:$PATH"

然后就可以跑测试了

1
2
3
4
5
6
7
8
9
magicdian@MacBook-Pro-14 tools % ./vts-tradefed
==================
Notice:
We collect anonymous usage statistics in accordance with our Content Licenses (https://source.android.com/setup/start/licenses), Contributor License Agreement (https://opensource.google.com/docs/cla/), Privacy Policy (https://policies.google.com/privacy) and Terms of Service (https://policies.google.com/terms).
==================
Android Vendor Test Suite 14_r3 (11237927)
Use "help" or "help all" to get more information on running commands.
01-09 19:43:58 I/DeviceManager: Detected new device 391QYGBXXXXXXX
vts-tf >