Android Docker 中的模拟器

Android emulator in Docker

我正在尝试在 docker 容器内启动 Android 模拟器,但出现错误:

root@686d602e6ffa:~/android-sdk-linux/tools# ./emulator            
ERROR: 32-bit Linux Android emulator binaries are DEPRECATED, to use them
       you will have to do at least one of the following:

       - Use the '-force-32bit' option when invoking 'emulator'.
       - Set ANDROID_EMULATOR_FORCE_32BIT to 'true' in your environment.

       Either one will allow you to use the 32-bit binaries, but please be
       aware that these will disappear in a future Android SDK release.
       Consider moving to a 64-bit Linux system before that happens.

但是容器里面的OS是(uname -a)

Ubuntu SMP Tue Mar 10 20:06:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

并且手动启动 emulatox64-x86 工作正常:

android-sdk-linux/tools# ./emulator64-x86 
emulator: ERROR: You did not provide the name of an Android Virtual Device
with the '-avd <name>' option. Read -help-avd for more information.

If you *really* want to *NOT* run an AVD, consider using '-data <file>'
to specify a data partition image file (I hope you know what you're doing).

我可能会做一个象征性的 link - 但我认为这不是一个好的解决方案,因为可能有不同的体系结构需要模拟

此外,此模拟器应由位于上述容器中的 Jenkins 启动

更新: 正如@user2915097 所建议的那样: root@686d602e6ffa:/# file /bin/bash /bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24

摘自https://github.com/docker/docker/issues/611

uname 将始终告诉您 64 位。看看例如"file /bin/sh" 查看文件系统的真正架构。

你可以做一个符号化的 link - 但我认为这不是一个好的解决方案,因为可能有不同的体系结构需要模拟

仅供参考:我 运行 基于 FROM ubuntu:16.04 在 docker 上进行了此操作,最后通过安装 "file" apt-get install file[= 解决了这个问题13=]

显然模拟器使用 file 查看 $SHELL 并且如果它不包含 "x86_64" 它认为它是 32 位。