Ubuntu logo

Developer

Using the Ubuntu Emulator

Using the Ubuntu Emulator in the SDK

Ubuntu emulators are a great way to develop apps, particularly when you do not have a physical device that currently runs Ubuntu.  Once an emulator is attached to the SDK, you can run apps on them, install click packages on them, and etc. just as if they were physical devices.

Here you learn how to use the Ubuntu emulator from the Ubuntu SDK, including:

  • Creating emulators
  • Launching an emulator
  • Attaching an emulator to the SDK
  • Opening a root shell to an emulator

Note: The Ubuntu emulator is under rapid development, including its support in the SDK. So stay nimble, stay tuned for new information, and keep alert for changes!

Tip: For the cutting edge Ubuntu emulator and SDK experience, update your system from the SDK PPA, as explained in the Installing the SDK tutorial.

What is the Ubuntu emulator?

The emulator is an instance of Ubuntu for phones and tablets that runs on your Desktop in a window instead of on a physical device.  It looks and operates the same as Ubuntu on a phone or tablet, but you use a mouse to interact with the GUI instead of physical touch and swipe gestures.

Tip: The emulator is slower than a physical device, so be patient.

Creating an emulator instance

  1. In the Ubuntu SDK, open the Devices tab. At the bottom select the Emulators tab.
  2. Near the top left, enter a name for your new emulator in the Name field.
  3. Click the Create new emulator button.

Note: It takes a while to create an emulator.

On success, the new emulator is listed on the right side of the Emulators tab with its name and other descriptive information, including the “version=NUMBER”, which is the build number of the Ubuntu for phones and tablets image.

Launching an emulator instance

  1. In the Ubuntu SDK, open the Devices tab. At the bottom select the Emulators tab.
  2. Select an emulator from those listed on the right side of the screen.
  3. Click Start selected emulator

Tip: It takes some time for an emulator to start.

emulator-

When the launch is complete, the emulator displays in a separate window. You interact with the GUI using your mouse and the onscreen keyboard, which displays when needed.

Attaching a running emulator to the SDK as a device

Once an emulator instance is running, you can attach it to the SDK as a device. This allows you to use the SDK to run apps on it and install click packages on it.

Tip: From the SDK point of view, physical devices and emulator devices are essentially the same.

  1. Verify your emulator instance is running in a window on your Desktop and its GUI is responsive.
  2. In the Ubuntu SDK, open the Devices tab and its Device Actions sub tab (at the bottom).
  3. Click the Redetect devices button.

On success, the SDK Devices tab displays a message starting with “Your device has been enabled for developer use.” And, the device Serial number field at the top displays the emulator instance serial number:

Your emulator is now attached and SDK capabilities that you could use on a physical Ubuntu device work on the emulator. For example, you can run an application directly from the SDK on the device.

Getting shell access to a running emulator

You can now open a shell to the emulator using the adb command as follows:

  1. Open a terminal shell with Ctrl + Alt + T
  2. Ensure the emulator is visible to adb with:
 $ adb devices 
 List of devices attached 
 emulator-5514         device 

“emulator-5514” is the Serial number of the emulator explained above.

  1. Create a root shell with:
 $ adb shell 
 root@ubuntu-phablet:/# 

Exit the shell with Ctrl + D.

More information

Next steps

Now that you have an emulator running as an attached device, you might check out the Running an app from the SDK tutorial.