<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Michael Xi on Medium]]></title>
        <description><![CDATA[Stories by Michael Xi on Medium]]></description>
        <link>https://medium.com/@michaelyukunxi?source=rss-87739abbddf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*H-3YZoREkPhuq3yPhuq7Nw.png</url>
            <title>Stories by Michael Xi on Medium</title>
            <link>https://medium.com/@michaelyukunxi?source=rss-87739abbddf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:22:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michaelyukunxi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android Cuttlefish Virtual Device Launch Automation: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@michaelyukunxi/android-cuttlefish-virtual-device-launch-automation-a-step-by-step-guide-1417360723d6?source=rss-87739abbddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1417360723d6</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-virtual-device]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Michael Xi]]></dc:creator>
            <pubDate>Tue, 01 Aug 2023 21:57:38 GMT</pubDate>
            <atom:updated>2023-08-01T21:57:38.784Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cuttlefish Introduction</h3><h4>What is Android Cuttlefish?</h4><p>Android Cuttlefish is an open-source Android Virtual Device (AVD) developed by Google. Its purpose is to run Android as a virtual machine on Linux-based systems for testing and development purposes. It leverages QEMU, a popular open-source emulator, and KVM, a hardware-assisted virtualization technology, to enable efficient virtualization and emulation of Android devices. This allows developers, researchers, and testers to work with AOSP without having access to a physical device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/0*c2xlCzxJ1tikf5SA.png" /></figure><ul><li><strong>Android Cuttlefish Documentation</strong>: <a href="https://source.android.com/docs/setup/create/cuttlefish">https://source.android.com/docs/setup/create/cuttlefish</a></li><li><strong>GitHub Link</strong>: <a href="https://github.com/google/android-cuttlefish">https://github.com/google/android-cuttlefish</a></li><li><strong>Cuttlefish Introduction Slide</strong>: <a href="https://2net.co.uk/slides/aosp-aaos-meetup/2022-march-cuttlefish.pdf">https://2net.co.uk/slides/aosp-aaos-meetup/2022-march-cuttlefish.pdf</a></li></ul><h4>Why do we need Android Cuttlefish?</h4><p>One important feature of Android Cuttlefish is its full fidelity to the Android framework. This means that Cuttlefish responds to your interactions just like a physical phone with the same or modified Android OS source. In other words, Android Cuttlefish is designed for Android OS or Android Kernel hackers. On the other hand, the Android emulator commonly seen in Android Studio is optimized for Android application development, with many functional hooks to appeal to the use cases of Android app developers. It is not suitable for OS developers.</p><h3>Cuttlefish Setup Guide — Automation</h3><h4>Step 0: Prerequisites</h4><ul><li><a href="https://old-releases.ubuntu.com/releases/22.04.1/">Ubuntu 22.04.1</a>: the following installation instructions have been tested on the Ubuntu Linux distribution with version 22.04.1. It is encouraged to use the same environment.</li><li><a href="https://github.com/MichaelXi3/android-cuttlefish-automation">Cuttlefish Launch Automation Github Repo</a>: provides shell scripts to automate the Android Cuttlefish launch. It also includes a Makefile to make the interaction with Cuttlefish easier by encapsulating android cuttlefish commands.</li></ul><h4>Step 1: On a Linux desktop, clone this repository and navigate to the android-cuttlefish-automation folder at the root level of the repository. Then, run the shell script.</h4><pre>git clone https://github.com/MichaelXi3/android-cuttlefish-automation.git</pre><pre>source ./create-android-cuttlefish.sh</pre><p><strong>Note</strong>: During Step 2 of the process, your laptop will <strong>reboot</strong>. Once the reboot is complete, execute the shell script again. The progress of shell scripts will be tracked, and previously completed commands will not be re-run. The reason for the reboot is to trigger the installation of additional kernel modules and the application of udev rules for Android cuttlefish.</p><h4>Step 2: Interact with Android Cuttlefish using Makefile</h4><p>After executing the shell script, you should be located in the ~android-cuttlefish/cf directory. The script also copied a Makefile to this directory to help you interact with the Android Cuttlefish virtual device. The commands are described as follows:</p><pre>make shell                  # enter the shell of Android Cuttlefish<br>make root                   # running as root<br>make stop                   # stop the cuttlefish device<br>HOME=$PWD ./bin/launch_cvd  # launch a new cuttlefish virtual device</pre><p>You also can add additional commands to this Makefile to make the interaction with Android cuttlefish more straightforward.</p><h3>Cuttlefish Setup Guide — Manual</h3><blockquote><em>For lastest manual launch instructions, check: </em><a href="https://android.googlesource.com/device/google/cuttlefish/"><em>https://android.googlesource.com/device/google/cuttlefish/</em></a></blockquote><h4>Step 1: In Linux desktop or virtual machine, make sure virtualization with KVM is available</h4><pre>grep -c -w &quot;vmx\|svm&quot; /proc/cpuinfo</pre><p>This should return a non-zero value. If running on a cloud machine, this may take cloud-vendor-specific steps to enable.</p><h4>Step 2: Download, build, and install the Cuttlefish host Debian packages</h4><pre>sudo apt install -y git devscripts config-package-dev debhelper-compat golang curl<br>git clone https://github.com/google/android-cuttlefish<br>cd android-cuttlefish<br>for dir in base frontend; do<br>  cd $dir<br>  debuild -i -us -uc -b -d<br>  cd ..<br>done<br>sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f<br>sudo dpkg -i ./cuttlefish-user_*_*64.deb || sudo apt-get install -f<br>sudo usermod -aG kvm,cvdnetwork,render $USER<br>sudo reboot</pre><p>This script installs the Android Cuttlefish environment on a Linux-based system.</p><h4>Step 3: Download OTA images and host package of Android Cuttlefish</h4><ul><li><strong>OTA</strong> (Over-The-Air) image: this file is a system image for the Cuttlefish Virtual Device (CVD), which is a part of AOSP.</li><li><strong>Host package</strong>: this file is a host package for Cuttlefish. It includes binaries and scripts that must be run on the host machine to set up and run the Cuttlefish virtual device.</li></ul><ol><li>Go to <a href="http://ci.android.com/">http://ci.android.com/</a></li><li>Enter a branch name. Start with aosp-master if you don‘t know what you’re looking for</li><li>Navigate to aosp_cf_x86_64_phone and click on userdebug for the latest build</li><li>Click on Artifacts</li><li>Scroll down to the <strong>OTA</strong> images. These packages look like aosp_cf_x86_64_phone-img-xxxxxx.zip -- it will always have img in the name. Download this file</li><li>Scroll down to cvd-host_package.tar.gz. You should always download a <strong>host package</strong> from the same build as your images</li><li>On your local system, cd /path/to/android-cuttlefish, combine the packages with the following code</li></ol><pre>mkdir cf<br>cd cf<br>tar xvf /path/to/cvd-host_package.tar.gz<br>unzip /path/to/aosp_cf_x86_64_phone-img-xxxxxx.zip</pre><h4>Step 4: Launch cuttlefish and other useful cuttlefish commands</h4><ul><li>Launch cuttlefish virtual machine</li></ul><pre>HOME=$PWD ./bin/launch_cvd</pre><pre># launch in daemon mode with specified disk, ram, and cpu<br>HOME=${PWD} ./bin/launch_cvd -daemon -memory_mb 27000 -data_policy always_create -blank_data_image_mb 30000 -cpus 1</pre><ul><li>Enable cuttlefish root</li></ul><pre>./bin/adb root</pre><ul><li>Launch cuttlefish shell</li></ul><pre>./bin/adb shell</pre><ul><li>Stop the cuttlefish virtual machine</li></ul><pre>pkill run_cvd</pre><h3>Reference and Useful Info</h3><ol><li>Google Cuttlefish Documentation: <a href="https://android.googlesource.com/device/google/cuttlefish/">Link</a></li><li>Virtual Machine in Android: Everything you need to know: <a href="https://medium.com/android-news/virtual-machine-in-android-everything-you-need-to-know-9ec695f7313b">Link</a></li><li>Cheatsheat of cuttlefish launch_cvd</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LrQ1BKuZGSivmfV--80rcg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1417360723d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>