Running Android Cuttlefish Virtual Device on Ghaf

Cuttlefish is a configurable virtual Android device (virtual-machine based Android emulator) that can run both remotely (using third-party cloud offerings such as Google Cloud Engine) and locally (on Linux x86 machines). For more information about Cuttlefish, see the official Cuttlefish Virtual Android Devices documentation.

You can run Android as a VM on Ghaf for testing and development purposes using NVIDIA Jetson Orin AGX (ARM64) or Generic x86.

Installing Cuttlefish

  1. Download host_package (includes binaries and scripts that must be run on the host machine to set up and run the Cuttlefish virtual device) and aosp_cf_phone-img (a system image) files from the Android CI server and copy them to Ghaf:

    Download a host package from the same build as the image.

  2. Make sure Internet connection is working in Ghaf. If the system gets an IP address but the DNS server is not responding, set the correct date and time.

  3. [For x86_64 only] Install the required packages:

    NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-env -i python3 openssl bash unzip
  4. Create some hackish links that are required for running Cuttlefish:

    sudo ln -s $(which mv) /bin/mv
    sudo ln -s $(which bash) /bin/bash
    sudo mkdir -p /usr/lib/cuttlefish-common/bin/
    sudo touch /usr/lib/cuttlefish-common/bin/
    sudo chmod 755 /usr/lib/cuttlefish-common/bin/
    sudo groupadd -f cvdnetwork
    sudo usermod -aG cvdnetwork $USER
    sudo usermod -aG kvm $USER
    sudo su ghaf
  5. Change directory to the one that contains host package and image files and extract them:

    • For NVIDIA Jetson Orin AGX (ARM64):

      tar xvf cvd-host_package.tar.gz
    • For Generic x86:

      tar xvf cvd-host_package.tar.gz
  6. [For x86_64 only] Extra steps to fix missing dependencies:

    • Find and create a link in /lib64:

      sudo find /nix/store -name
      sudo mkdir /lib64
      sudo ln -s /nix/store/dg8mpqqykmw9c7l0bgzzb5znkymlbfjw-glibc-2.37-8/lib/ /lib64
    • Find in the /nix/store and copy it to the lib64 directory where the host package was extracted:

      sudo find /nix/store -name
      cp /nix/store/2jdx0r0yiz1k38ra0diwqm5akb0k1rjh-libdrm-2.4.115/lib/ ./lib64

Running Cuttlefish

Go to the directory with exctacted host package and image files and run Cuttlefish:

HOME=$PWD ./bin/launch_cvd -report_anonymous_usage_stats=n

It will take some time to load. There should be the following messages in the console when the VM is booted and ready to use:

Virtual device booted successfully

Connecting to Cuttlefish Device

  1. Run the Chromium browser by clicking on the corresponding icon in Weston and navigate to https://localhost:8443. Ignore a warning about the SSL certificate (“Your connection is not private“) and click Advanced > Proceed to (unsafe).

  2. Click the cvd-1 Connect button. A new tab with an Android VM window will be opened.

  3. [Optionally] You can close the browser and use the following command to open a standalone window with an Android VM:

chromium-browser --enable-features=UseOzonePlatform --ozone-platform=wayland --new-window --app=