How to Install CuttleFish on Ubuntu 24.04
Notes of compiling & installing CuttleFish.
Prerequisites
Bazel:
$ sudo apt install apt-transport-https curl gnupg -y
$ curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg
$ sudo mv bazel-archive-keyring.gpg /usr/share/keyrings
$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ sudo apt update && sudo apt install bazel
libtinfo.so.5
:
$ sudo apt update
$ wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
$ sudo apt install ./libtinfo5_6.3-2ubuntu0.1_amd64.deb
Compilation
CuttleFish:
$ sudo apt install -y git devscripts config-package-dev debhelper-compat golang curl
$ git clone git@github.com:google/android-cuttlefish.git
$ cd android-cuttlefish
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
$ for dir in base frontend; do
cd $dir
debuild -i -us -uc -b -d
cd ..
done
$ sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
$ sudo dpkg -i ./cuttlefish-user_*_*64.deb || sudo apt-get install -f
$ sudo usermod -aG kvm,cvdnetwork,render $USER
$ sudo reboot
AOSP (better running under root
privilege):
$ mkdir <AOSP> && cd <AOSP>
$ repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r55
$ repo sync -j$(nproc)
$ source build/envsetup.sh
# Disable errors from nsjail
# $ sudo sysctl -w kernel.apparmor_restrict_unprivileged_unconfined=0
# $ sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
# Enable user's access on disk
# $ sudo usermod -gG disk $USER
# Arm64
# $ lunch aosp_cf_arm64_phone-ap2a-userdebug
$ lunch aosp_cf_x86_64_phone-ap2a-userdebug
$ m -j$(nproc)
AOSP Kernel:
$ mkdir <AOSP-KERNEL> && cd <AOSP-KERNEL>
$ repo init -u https://android.googlesource.com/kernel/manifest -b common-android-mainline
$ repo sync -j$(nproc)
# Arm64
# $ tools/bazel run //common:kernel_aarch64_dist
# Arm64
# $ tools/bazel run //common-modules/virtual-device:virtual_device_aarch64_dist
$ tools/bazel run //common:kernel_x86_64_dist
$ tools/bazel run //common-modules/virtual-device:virtual_device_x86_64_dist
Running & Debugging
Commands for controlling the CuttleFish virtual machine:
$ launch_cvd --daemon
$ cvd_status # using `adb shell` to interact with the virtual device
$ stop_cvd
Replace kernel with compiled one:
$ launch_cvd -kernel_path <AOSP-KERNEL>/out/virtual_device_x86_64/dist/bzImage \
-initramfs_path <AOSP-KERNEL>/out/virtual_device_x86_64/dist/initramfs.img --daemon
References
搭建 Cuttlefish 运行环境
在 Ubuntu 上安装 Bazel
How to install libtinfo5 on Ubuntu24.04
基于 Cuttlefish 调试 Android 内核
Ubuntu 24.x “permission denied” in mount(/, /) #236