Getting the emulator

Minimal System requirements for the emulator

  • 512MB of RAM dedicated for the emulator
  • 4GB of disk space
  • OpenGL capable desktop drivers (due the OpenGLES 2.0 translator)

Installing the pre-built emulator


  • Install the ubuntu-emulator package
  • Create an instance (and/or select the desired arch to use)
  • Run the emulator

sudo apt install ubuntu-emulator
sudo ubuntu-emulator create myinstance (you can use any name for "myinstance")
ubuntu-emulator run myinstance

To create a X86 instance, just give --arch=i386 to ubuntu-emulator create:

sudo ubuntu-emulator create --arch=i386 myinstance
ubuntu-emulator run myinstance


  • By default, the latest built image from devel channel is used.
  • XDG_CACHE_DIR/ubuntuimage is used to download images; it is shared with ubuntu-device-flash.
  • Images are stored in XDG_DATA_DIR/ubuntu-emulator.
  • To update to a latest image; it is safe to create over the previous instance (upgrade option comming soon).
  • Once migrated to this ubuntu-emulator-images and android-emulator can be safely removed.
  • All references to run-emulator.sh and build-emulator-sdcard.sh do no apply anymore.
  • Snapshotting is taken care of with the snapshot subcommand from ubuntu-emulator.
  • If ubuntu-emulator run fails with libGL error: Couldn't dlopen libudev.so.1 or libudev.so.0, driver detection may be broken on amd64, this is bug:1291333. You can work around this by doing sudo apt install libudev1:i386

  • If 'ubuntu-emulator create' fails with "qemu-img: Invalid options for file format 'qcow2'", you may need to use a raw disk as per https://lists.launchpad.net/ubuntu-phone/msg08072.html

  • The new emulator instance is created with the phablet user password set to: 0000. Passwords entered on the initial wizard security screen will be ignored. A new option has been added to the latest version of ubuntu-emulator in vivid: --password= which can be used to override the default password.


Until system-image works in the emulator, you can do the following to rebuild the image using the cached image:

$ sudo ubuntu-emulator create myoldinstance

Building from scratch

The Ubuntu emulator is composed of two parts: the runtime (what gets the emulator running) and the manager (the set of commands to start/stop and manage emulator instances).

To build the runtime:

$ sudo apt install phablet-tools git bzr

$ # install android build-dependencies
$ sudo apt build-dep android

$ # if we're on amd64, we need to pull in certain 32-bit packages explicitly
$ sudo apt install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386 zlib1g-dev:i386

$ # this here is only needed if you didn't follow https://wiki.ubuntu.com/Touch/Porting before
$ sudo apt install schedtool openjdk-8-jdk g++-multilib bison flex

$ # and then work around the fact that libgl1-mesa-dev isn't Multi-Arch: same yet
$ sudo ln -s /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so

$ mkdir -p emulator/
$ phablet-dev-bootstrap emulator
$ cd emulator
$ source build/envsetup.sh
$ lunch aosp_arm-userdebug # or aosp_x86-userdebug for the x86 emulator
$ make -j<n>
  • Note: If you're using Ubuntu Trusty (14.04) as your host, make sure you don't have the package gcc-i686-linux-android installed in your system. This toolchain has a bug that breaks the emulator init system, and you should either use the Android pre-build one (by removing the package), or downloading the latest gcc-i686-linux-android from Ubuntu Utopic (14.10).

To use the system.img that you just created, create an instance with ubuntu-emulator create --use-raw-disk and replace the system.img file available in the generated sdcard.img file (under ~/.local/share/ubuntu-emulator/<my instance>:

$ simg2img out/target/product/generic_x86/system.img out/target/product/generic_x86/system.raw
$ sudo mount ~/.local/share/ubuntu-emulator/myinstance/sdcard.img /tmp/mount1
$ sudo mount /tmp/mount1/system.img /tmp/mount2
$ sudo cp out/target/product/generic_x86/system.raw /tmp/mount2/var/lib/lxc/android/system.img
$ sudo umount /tmp/mount2
$ sudo umount /tmp/mount1

To build the manager:

sudo apt install golang-go
export GOPATH=$HOME/go
mkdir $GOPATH
export PATH=$PATH:$GOPATH/bin
go get launchpad.net/goget-ubuntu-touch/ubuntu-emulator

Username & password are:


To update your existing working tree to pull in new changes from the server, run repo sync.

For more information about how to use the repo command to manage your android working tree, see this page.

Support Status

Please check Support status to better know what is the current state of the emulator.

Using the emulator

After starting the emulator with the wrapper script, the following should be available:

  • Adb
    • Emulator will appear in the output of $ adb devices, and will, once fully booted, allow
      $ adb shell
      access into ubuntu.
  • SSH access
    • SSH is enabled by default in the emulator, but you can only access it via localhost (QEMU handles the routes and NAT internally). All you need is to forward the target SSH port to a known port at your host:
      $ adb forward tcp:9999 tcp:22
      $ ssh phablet@localhost -p 9999
  • Telnet access
    • Once launched, the graphical window title will show a port number, e.g. 5554. Connect to that over telnet to send hardware events to the emulator
      $ telnet 5554
      Connected to
      Escape character is '^]'.
      Android Console: type 'help' for a list of commands
      Android console command help:
          help|h|?         print a list of commands
          event            simulate hardware events
          geo              Geo-location commands
          gsm              GSM related commands
          cdma             CDMA related commands
          kill             kill the emulator instance
          network          manage network settings
          power            power related commands
          quit|exit        quit control session
          redir            manage port redirections
          sms              SMS related commands
          avd              control virtual device execution
          window           manage emulator window
          qemu             QEMU-specific commands
          sensor           manage emulator sensors
      try 'help <command>' for command-specific help
  • Accessing your host device from the emulator:
    • You can access your host machine by using the IP from inside the emulator. During development you can either use that to ssh your host, or access any other service running in your host machine, such as a web server.

  • Autopilot
    1. Start up emulator with ubuntu-emulator as per above.

    2. Get emulator serial:
      • $ adb devices
        List of devices attached
        emulator-5554 device
        emulator-5556 device
    3. Pass -s emulator-XXXX to phablet-config and phablet-test* commands

    4. otherwise use same as described in https://wiki.ubuntu.com/Touch/Testing#Testing_your_Ubuntu_Touch_Code_before_submission, but without "phablet-flash" step for the time being.

Handling disk snapshots

Being able to create a snapshot and roll back to it is very useful for developers. Eg, developers can

  • develop features, etc on the image, then package them up, roll back the image and test on a pristine image
  • save time on system-image upgrade testing
  • do multiple test runs, reverting to the pristine image between runs to cut down on variances
  • verify bugs in the image easily
  • etc


ubuntu-emulator handles disk snapshots:

$ ubuntu-emulator snapshot --help
  ubuntu-emulator [OPTIONS] snapshot [snapshot-OPTIONS]

Create and revert to snapshots of the emulator instance name 'name' which was previously created

Help Options:
  -h, --help             Show this help message

Manipulates snapshots for emulator instance named 'name':
      --revert=          Reverts to the selected snapshot
      --create=          Creates the selected snapshot
      --revert-pristine  Reverts to the originally created snapshot

Help Options:
  -h, --help             Show this help message

Qcow2 images with snapshots are used by default when creating images with ubuntu-emulator create. The basic workflow is:

$ sudo ubuntu-emulator create trusty
$ ubuntu-emulator run trusty
<do work>
<shutdown or close the emulator with window/ctrl-c>
$ ubuntu-emulator snapshot --revert-pristine trusty
$ ubuntu-emulator run trusty
<perform tests in pristine environment>
<shutdown or close the emulator with window/ctrl-c>
$ ubuntu-emulator snapshot --revert-pristine trusty

Because a number of things happen on first boot after creating the image (or updating via system-image, which isn't supported yet, but will be), the first boot is very slow. You can workaround this by updating your pristine snapshot after your first boot, like so:

$ sudo ubuntu-emulator create trusty
$ ubuntu-emulator run trusty # first boot, be patient and wait until unity8 comes up
$ adb shell shutdown -h now  # wait until system is halted, then close the emulator with window/ctrl-c
$ ubuntu-emulator snapshot --create=pristine trusty

The above boots the emulator, cleanly shuts it down and then updates the pristine snapshot. See ubuntu-emulator snapshot --help for more details.

Keyboard Commands

Emulated Device Key

Keyboard Key

Power button


Audio volume up button


Audio volume down button


Switch to previous layout orientation (for example, portrait, landscape)

KEYPAD_7, Ctrl-F11

Switch to next layout orientation (for example, portrait, landscape)

KEYPAD_9, Ctrl-F12

Known Issues

  • The first boot might take a few minutes as it generates the ssh key, install the click packages and so on. It shouldn't take too much though, always check with adb if the emulator is still running correctly (e.g. check with top).
  • It's quite common for Qemu to hang while booting (like an I/O-type hang), just abort and restart the emulator (still needs proper debugging).
  • If Unity8 fails to start, make sure your i386 GL driver is properly in place (check for error libGL.so.1: cannot open shared object file: No such file or directory when starting the emulator). If everything goes well, you should see 'qemu.gles=1' in the qemu kernel parameters.

  • For running the emulator in a VM guest (e.g. Ubuntu in VMware Player) a VT-d enabled processor is needed and the proper option for supporting nested virtualization must be set in the hypervisor (e.g. in VMware Player the "Virtualize Intel VT-x/EPT or AMD-V/RVI" Option must be set).


Touch/Emulator (last edited 2016-04-15 03:17:10 by tsimonq2)