Cuttlefish is new virtual-machine based Android emulator. Earlier I have written an article on how to build/run it on PC and ARM64 machines. Towards the end of 2019, AWS has introduced a1.metal instance which allows KVM to run on their ARM64 machines. It opens the possibility of running cuttlefish on AWS (which itself opens a lot of possibilities!)
The steps are similar to those I mentioned before. This article summarizes them here specifically for AWS a1.metal instance, running Ubuntu 19.10.
Build AOSP cuttlefish images on x86_64
This step is done on PC, while all the rest steps are done on AWS a1.metal instance.
- Refer to https://source.android.com/setup/build/building to set up your host machine
- Check out the source from master and build distribution packages, which will be transferred to a1.metal instance later. This step takes very loooong time.
repo init -u https://android.googlesource.com/platform/manifest
repo sync -j8
Setup AWS a1.metal
Start an Ubuntu 19.10 instance on a1.metal. First, we install GUI for better debugging and viewing.
sudo apt-get update -y
sudo apt-get install lxde xrdp -y
sudo passwd ubuntu
Setup to run x86_64 binaries
Many tools (e.g., cros_vm) are x86_64 binaries. Thus we need to use qemu-user to run those binaries (*ugly*). As such, we also need to set up amd64 as the secondary architecture.
- Override /etc/apt/sources.list file with the following content
deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports eoan main restricted universe multiverse
deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports eoan-updates main restricted universe multiverse
deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports eoan-backports main restricted universe multiverse
deb [arch=arm64,armhf] http://ports.ubuntu.com/ubuntu-ports eoan-security main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ eoan main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ eoan-updates main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ eoan-backports main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ eoan-security main restricted universe multiverse
- Install qemu-user-static and add amd64 secondary architecture
sudo apt install qemu-user-static
sudo dpkg --add-architecture amd64
sudo apt install libc6:amd64
- After this you should be able to run simple x86_64 binaries such as “cat”.
- scp over “cat” program from your x86_64 linux machine
- it should run!
Build and install cuttlefish-common package
- install packages needed for build
sudo apt install dpkg-dev
sudo apt install cdbs config-package-dev debhelper
- Download and build
git clone https://github.com/google/android-cuttlefish.git
sudo apt install bridge-utils dnsmasq-base f2fs-tools libarchive-tools libfdt1 libwayland-client0 net-tools python2
sudo dpkg -i ../cuttlefish-common_0.9.13_arm64.deb
Setup cuttlefish for running
- copy (scp) the following the files from x86_64 PC host:
- untar cvd-host_package.tar.gz to ~/cuttlefish/host directory
- unzip the zip file to ~/cuttlefish/image directory
- Add user to proper groups before running; power off machine; then power on again.
sudo usermod -aG kvm $USER
sudo usermod -aG cvdnetwork $USER
You have 2 choices to view the running Android screen:
- Use remote desktop and view screen via local VNC connection
- Use a web browser and view the screen via remote WebRTC connection
View via Local VNC
- Start a remote desktop viewer and connect to your a1.metal instance (Note: you need to open port 3389)
- Start a LXTerminal and run the following commands to start cuttlefish
- Start browser and download VNC viewer
- download tightvnc viewer (jar file): https://www.tightvnc.com/download.php
- install java if not done yet: sudo apt install openjdk-11-jre
- Start a second LXTerminal and run this command : java -jar tightvnc-jviewer.jar
- Please use 127.0.0.1 as IP address and 6444 as port number
- To stop cvs, run stop_cvd
View via WebRTC
- Start a LXTerminal and run
launch_cvd -start_webrtc -webrtc_public_ip=`curl http://169.254.169.254/latest/meta-data/public-ipv4` -decompress_kernel=true
- start a browser on local machine, and connect via “https://<public IP>:8443”
As of writing today (4/5, 2020), the WebRTC method is not working. It shows a black screen.