Table of Contents

Installing Android emulator on Debian 10

If installing on Proxmox LXC container, the container needs to be a privileged one

Make a backup of unprivileged and restore it as privileged if you first installed everything in unprivileged one.

Enable “Nesting” in Options>Features.

Add this to /etc/pve/lxc/container.conf

lxc.cgroup.devices.allow = c 10:232 rwm
lxc.hook.autodev = sh -c "mknod -m 0666 ${LXC_ROOTFS_MOUNT}/dev/kvm c 10 232"

Install qemu/kvm

  apt install --no-install-recommends qemu-kvm libvirt-clients libvirt-daemon-system libpulse0 libgl1 libxcomposite1 libxcursor1 bridge-utils

Check if you can connect

  virsh --connect qemu:///system list

Install system images

Find necessary images with

  sdkmanager --list

Install them

  sdkmanager 'system-images;android-19;google_apis;x86' 'system-images;android-23;google_apis;x86_64' 'system-images;android-29;google_apis;x86_64'

NOTE: *apis_playstore will NOT work for emulation!!!

Create new emulated device with system image

  avdmanager create avd --name android29_x86_64 --package 'system-images;android-29;google_apis;x86_64'

Run Android virtual device (AVD)

  emulator -avd android19_x86 -port 5556 -noskin -noaudio -no-window -qemu -m 512 -enable-kvm

Output should be similar to:

  root@host:/opt/android-sdk/tools/bin# /opt/android-sdk/tools/emulator -avd android29_x86_64 -port 5556 -noskin -noaudio -no-window -qemu -m 1024 -enable-kvm 
  emulator: WARNING: the -no-skin flag is obsolete. to have a non-skinned virtual device, create one through the AVD manager
  statvfs('/root/.android/avd/android29_x86_64.avd/snapshots/default_boot/ram.img') failed: No such file or directory
  emulator: Requested console port 5556: Inferring adb port 5557

adb devices should report:

  root@host:/opt/android-sdk/platform-tools# ./adb devices
  List of devices attached
  emulator-5556	device

If “adb devices” shows a device as unathorized, check the ~/.android directory if the adbkey and adbkey.pub exist and also try removing/renaming the folder and restarting the server with:

  adb kill-server
  adb start-server

This should regenerate the keys.

Tested on

See also

Sign android apk from terminal

References