Create and test a virtual device

Before you start, complete: Install the appliance but when initializing, remember to answer Yes to the question: Do you want to setup access to the AMS API for your current user (ubuntu, uid=1000)?

In this tutorial, we will go through the first steps of using Anbox Cloud to create a virtual Android device. By virtual device, we mean a simulated device that runs a plain Android operating system without any special apps installed. Anbox Cloud treats such a virtual device as an empty application, meaning an application that is not running a specific APK.

By the end of this tutorial, we will be familiar with an Application and an Instance in Anbox Cloud that are used to create and stream the virtual Android device.

This tutorial has two paths - you can use the CLI or the dashboard, depending on your learning goals. The CLI is more powerful and gives you access to all features of Anbox Cloud, while the dashboard is a simpler user interface. For this tutorial, it does not matter which path you choose.

We will use the Anbox Management Client (AMC) in this tutorial to work with applications and instances. AMC communicates with the Anbox Management Service (AMS), the instance management module of Anbox Cloud.

Create the device

The first step is to create a yaml file that can be used as the application manifest. It is important that this file is created in your home directory.

In the home directory, let’s first create a directory for the application content:

  mkdir my-app

This directory is the location where the application manifest file and any relevant application artifacts must reside.

For this tutorial, we are going to create a device with a basic application without an APK that will start directly with the Android system launcher.

Let’s first create the manifest.yaml inside the my-app directory with the following contents:

name: my-first-app
resources:
   cpus: 4
   memory: 4GB
   disk-size: 3GB

This example will use the default image as we haven’t mentioned a specific image.

Now, let’s create the application:

  amc application create my-app/

This command will return the application ID.

ubuntu@vm:~$ amc application create my-app/
cv3a7ofg2e7td2g9smt0

my-app/ is the application directory where the manifest and any other application related artifacts are available. The command should return the application ID.

The application is created and bootstrapped. Now, to see the application details and its status, run:

  amc application list

The output of this command should look similar to the following. Watch this output till the application becomes ready. The time taken for the application to become ready could depend on your network speed but with a good network connection, it shouldn’t take more than 10 minutes.

ubuntu@vm:~$ amc application list
+----------------------+--------------+---------------+--------+------+-----------+--------------+---------------------+-------+|          ID          |     NAME     | INSTANCE TYPE | ADDONS | TAGS | PUBLISHED |    STATUS    |    LAST UPDATED     |  VM   |+----------------------+--------------+---------------+--------+------+-----------+--------------+---------------------+-------+| cv3a7ofg2e7td2g9smt0 | my-first-app | a2.3          |        |      | false     | initializing | 2025-03-04 12:25:29 | false |+----------------------+--------------+---------------+--------+------+-----------+--------------+---------------------+-------+

Test the virtual device

Launch an instance

When the application is ready, let’s launch an instance:

  amc launch my-first-app --enable-streaming
ubuntu@vm:~$ amc launch my-first-app --enable-streaming
cv3ct202cdutj02fttsg

This command creates and starts an instance for the application.

my-first-app is the application name, you can also use the application ID to launch an instance for it.

The --enable-streaming flag indicates that we want to stream this instance.

To see the instance details and its status, run:

  amc ls

You will see an output similar to the following:

ubuntu@vm:~$ amc ls
+----------------------+------+--------------+------+---------+------+------+---------+-----------+-------+----------------+|          ID          | NAME | APPLICATION  | TYPE | STATUS  | TAGS | NODE | ADDRESS | ENDPOINTS |  VM   | STATUS MESSAGE |+----------------------+------+--------------+------+---------+------+------+---------+-----------+-------+----------------+| cv3ct202cdutj02fttsg |      | my-first-app | base | created |      |      |         |           | false |                |+----------------------+------+--------------+------+---------+------+------+---------+-----------+-------+----------------+

When the instance reaches the running status, the output for amc ls should look like:

ubuntu@vm:~$ amc ls
+----------------------+------+--------------+---------+---------+------------------------------+------+--------------+-----------+-------+----------------+|          ID          | NAME | APPLICATION  |  TYPE   | STATUS  |             TAGS             | NODE |   ADDRESS    | ENDPOINTS |  VM   | STATUS MESSAGE |+----------------------+------+--------------+---------+---------+------------------------------+------+--------------+-----------+-------+----------------+| cv3ct202cdutj02fttsg |      | my-first-app | regular | running | session=cv3ct202cduikviuu6rg | lxd0 | 192.168.96.1 |           | false |                |+----------------------+------+--------------+---------+---------+------------------------------+------+--------------+-----------+-------+----------------+

Now, let’s try to access the instance. We will need to copy the instance ID from the previous command’s output.

  amc shell instance_id

This takes us into the Linux instance that runs the Android container. Next, let’s try accessing the nested Android container:

  anbox-shell

Now, we are inside the Android container. Play around by running some of the following commands:

  ls
  logcat
  exit

exit or pressing Control+D takes us back to the Linux container.

Update an application

We can have several versions of an application. Let’s try and update the application:

Go to the application directory and update the manifest file. This manifest introduces a change to the disk-size.

name: my-first-app
resources:
   cpus: 4
   memory: 4GB
   disk-size: 8GB

Now, run the following commands and observe the output:

  amc application update my-first-app my-app/
  amc application list
  amc application show my-first-app

The list command displays the list of applications available. As an application becomes active, it is automatically published and a new version of the my-first-app is created.

The show command displays the application information along with its versions:

ubuntu@vm:~$ amc application show my-first-app
id: cv3a7ofg2e7td2g9smt0name: my-first-appcreated-at: 2025-03-04 15:19:32 +0530 ISTstatus: readypublished: trueimmutable: falseinhibit-auto-updates: falsetags: []node-selector: []parent-image: jammy:android14:amd64parent-image-variant: androidabi: x86_64vm: falseconfig:  instance-type: a2.3versions:  0:    image: jammy:android14:amd64 (version 0)    published: true    status: active    extra-data: {}    video-encoder: gpu-preferred    watchdog:      disabled: false      allowed-packages: []  1:    image: jammy:android14:amd64 (version 0)    published: true    status: active    extra-data: {}    video-encoder: gpu-preferred    watchdog:      disabled: false      allowed-packages: []resources:  cpus: 4  memory: 4GB  disk-size: 8GB

Now if we launch our application without explicitly specifying a version, our latest published version will be considered:

ubuntu@vm:~$ amc launch my-first-app
cv3d5ag2cdutj02fttvg
ubuntu@vm:~$ amc ls
+----------------------+------+--------------+---------+---------+------------------------------+------+--------------+-----------+-------+----------------+|          ID          | NAME | APPLICATION  |  TYPE   | STATUS  |             TAGS             | NODE |   ADDRESS    | ENDPOINTS |  VM   | STATUS MESSAGE |+----------------------+------+--------------+---------+---------+------------------------------+------+--------------+-----------+-------+----------------+| cv3ct202cdutj02fttsg |      | my-first-app | regular | running | session=cv3ct202cduikviuu6rg | lxd0 | 192.168.96.1 |           | false |                |+----------------------+------+--------------+---------+---------+------------------------------+------+--------------+-----------+-------+----------------+| cv3d5ag2cdutj02fttvg |      | my-first-app | regular | running |                              | lxd0 | 192.168.96.2 |           | false |                |+----------------------+------+--------------+---------+---------+------------------------------+------+--------------+-----------+-------+----------------+

Notice how the second instance launched without the --enable-streaming flag does not have a session ID. This instance cannot be streamed while the earlier one we created can be streamed.

Streaming the application

To look at a visual output of the stream-enabled instance that we created, we need a stream client.You can set up your own stream client by following the Set up a stream client later. For this tutorial, you can use the default client, the Anbox Cloud dashboard.

Go to https://machine-address using a browser and go to the Instances page where we can see the instance we created. See the Dashboard tab for details on using the dashboard to test the virtual device.

Success!

You now know how to use the command line to create and test an Android virtual device in Anbox Cloud.

Next: You can check out the following how-to sections to try out other applications with applications and instances: