Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86 or x86_64 Android emulator cannot run on the Docker machine #18

Closed
ozmium opened this issue Sep 23, 2018 · 1 comment
Closed

x86 or x86_64 Android emulator cannot run on the Docker machine #18

ozmium opened this issue Sep 23, 2018 · 1 comment

Comments

@ozmium
Copy link
Contributor

ozmium commented Sep 23, 2018

You can create an x86_64 Android emulator in this Docker image. But it cannot run at all. Example, using guidelines from Sam Edwards, with a custom bash script:

#!/bin/bash

# Create an x86 emulator from scratch, with a 100 MB SD card storage space. See
# https://handstandsam.com/2016/04/23/using-the-android-emulator-for-continuous-integration/
# You have to echo "no" because it will ask if you want to use a custom hardware profile,
# and you don't.
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd \
    -n Android_7.1_API_25 \
    -k "system-images;android-25;google_apis;x86_64" \
    -c 100M \
    --abi google_apis/x86_64 \
    --force

If you try to launch this emulator, it will not work:

# Verify that an AVD image is available
emulator -list-avds # This will output: Android_7.1_API_25

# Launch the emulator now
$ANDROID_HOME/tools/emulator -avd Android_7.1_API_25 &

It will just display this error:

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.

Even if you try to use the 32-bit flags, as per these instructions, it will still not work:

export ANDROID_EMULATOR_FORCE_32BIT=true
# Launch the emulator now
$ANDROID_HOME/tools/emulator -avd Android_7.1_API_25 -force-32bit &

You will get this error:

[1234567890]: ERROR: ./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib/qt/lib
Could not launch '../emulator/qemu/linux-x86/qemu-system-x86_64': No such file or directory

And this problem is documented here: https://stackoverflow.com/questions/42554337/cannot-launch-avd-in-emulatorqt-library-not-found

There is an alternate 'emulator' binary located at $ANDROID_HOME/emulator/emulator

But even this will not work to launch an x86 image:

$ANDROID_HOME/emulator/emulator -avd Android_7.1_API_25 &

Or

$ANDROID_HOME/emulator/emulator -use-system-libs -avd Android_7.1_API_25 -no-skin -no-audio -no-window -force-32-bit &

This will result in the following error:

emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: KVM requires a CPU that supports vmx or svm

And this problem is documented here: https://askubuntu.com/questions/564910/kvm-is-not-installed-on-this-machine-dev-kvm-is-missing and https://stackoverflow.com/questions/29136173/emulator-error-x86-emulation-currently-requires-hardware-acceleration

If you try to install the KVM software in the Docker machine, it will just fail at the sudo command -- sudo is not found, or not allowed.


The only thing that works for me is to use an ARM-based emulator instead of the x86 version, using the guidelines from https://medium.com/@AndreSand/android-emulator-on-docker-container-f20c49b129ef and https://paulemtz.blogspot.com/2013/05/android-testing-in-headless-emulator.html :

# Add missing folder to the PATH, to use sdkmanager
ANDROID_TOOLS=$ANDROID_HOME/tools/bin
PATH=$ANDROID_TOOLS:$PATH

# Download an ARM system image to create an ARM emulator.
sdkmanager "system-images;android-16;default;armeabi-v7a"

# Create an ARM AVD emulator, with 100MB SD card storage space.
echo "no" | avdmanager create avd \
    -n Android_4.1_API_16 \
    -k "system-images;android-16;default;armeabi-v7a" \
    -c 100M \
    --force

$ANDROID_HOME/emulator/emulator -avd Android_4.1_API_16 -no-skin -no-audio -no-window -no-boot-anim -gpu off &

So perhaps the x86 system images should not be included in the Docker image by default?

@ozmium ozmium changed the title Launching Android emulator results in "ERROR: 32-bit Linux Android emulator binaries are DEPRECATED" x86 Android emulator cannot run on the Docker machine Sep 28, 2018
@ozmium ozmium changed the title x86 Android emulator cannot run on the Docker machine x86 or x86_64 Android emulator cannot run on the Docker machine Sep 28, 2018
ozmium added a commit to ozmium/docker-android-build-box that referenced this issue Oct 9, 2018
Do not install the x86_64 emulator system image file, as it cannot run in the Docker image.

Example:

# Create an x86 emulator
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd \
    -n Android_7.1_API_25 \
    -k "system-images;android-25;google_apis;x86_64" \
    -c 100M \
    --abi google_apis/x86_64 \
    --force

# Try to launch the emulator
$ANDROID_HOME/tools/emulator -avd Android_7.1_API_25 &

# You will get this error: "ERROR: 32-bit Linux Android emulator binaries are DEPRECATED..."
# Or this error: "ERROR: ./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib/qt/lib"

# Try to launch the emulator with alternate binary
$ANDROID_HOME/emulator/emulator -use-system-libs -avd Android_7.1_API_25 -no-skin -no-audio -no-window -force-32-bit &

# You will get this error: "emulator: ERROR: x86_64 emulation currently requires hardware acceleration! Please ensure KVM is properly installed and usable..."

More info in ticket mingchen#18.
ozmium added a commit to ozmium/docker-android-build-box that referenced this issue Oct 9, 2018
Add instructions on how to create and launch an ARM emulator in the Docker image. Mention that x86_64 emulators do not work currently.
mingchen added a commit that referenced this issue Oct 13, 2018
Issue #18 fix patch: Remove pre-installed x86_64 emulator. Explain how to create and launch an ARM emulator
@daonb
Copy link

daonb commented Feb 11, 2023

I just found this and I'm a bit confused. Can x86 emulators runs in docker? I read the this issue comments, code and README and I figured it can't.
IMO, this should be left open until there's support for x86.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants