
After countless trials and errors, I finally did it—I successfully got AOSP up and running on my Ubuntu machine! This time, I installed Ubuntu 18.04 directly on my old Linux laptop from System76, which I had purchased while living in the US. The moment I saw the Android screen appear on my PC, I couldn’t help but applaud—just me, celebrating that hard-earned victory. Here’s what I have to say.
Important: Do not follow Google’s official instructions — they led to numerous unexpected errors when I tried!
When I followed the official instructions on Google’s AOSP page, I encountered numerous unexpected errors. Therefore, I strongly recommend following my instructions instead, as they are far more likely to help you successfully download, install, and run AOSP smoothly in your environment.

Remove the outdated or broken ‘repo’ tool if installed via package manager
sudo apt remove repo
My instruction:
Install essential tools for downloading and cloning the AOSP source
sudo apt install curl git -y
Create a bin directory in your home folder to store the latest ‘repo’ tool
mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Add the bin directory to your PATH so the system can recognize ‘repo’ command
And reload your bash settings to reflect the updated PATH
echo 'export PATH=~/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
Verify repo is properly installed
repo --version
Create a directory for AOSP source code (Android 12) and navigate into it
mkdir -p ~/aosp/aosp12 && cd ~/aosp/aosp12
Initialize the repo client with the Android 12 manifest
repo init -u https://android.googlesource.com/platform/manifest -b android-12.0.0_r13

Download all the source code for AOSP using all available CPU cores
repo sync -j$(nproc)
Navigate into your AOSP source directory
cd ~/aosp/aosp12
Source the environment setup script which defines useful build functions
source build/envsetup.sh
Choose a target device configuration for building
lunch sdk_phone_x86_64
Build the entire AOSP system using parallel jobs based on available cores
make -j$(nproc)
Launch the emulator to test your freshly built AOSP system
emulator
Fixing KVM Permissions for Android Emulator on Linux
If your Android emulator throws a message like:
ERROR: x86_64 emulation currently requires hardware acceleration!
This user doesn't have permissions to use KVM (/dev/kvm).
You can follow these steps to fix it.
Step-by-step KVM Setup & Fixes
Loads the KVM kernel module for Intel CPUs.
If you’re using an AMD CPU, replace it with kvm_amd.
sudo modprobe kvm_intel # or kvm_amd depending on your CPU
Adds your current user to the kvm group, which grants access to /dev/kvm.
sudo gpasswd -a $USER kvm
Applies group changes without rebooting or re-logging in. It starts a new shell with updated group membership.
newgrp kvm
Verifies your current groups. You should see kvm in the list if the previous step succeeded.
groups
Checks the permissions of /dev/kvm.
ls -l /dev/kvm
You should see something like:
crw-rw---- 1 root kvm ...
This means the device belongs to group kvm, and has read/write access for the group.
If the kvm group doesn’t exist (very rare)
Creates the kvm group manually (just in case your distro didn’t have it pre-defined).
Optional: Persistent udev rule (only if permissions keep resetting)
sudo nano /etc/udev/rules.d/50-kvm.rules
Opens a custom udev rule file for editing. Add this content inside:
KERNEL=="kvm", GROUP="kvm", MODE="0660"
Manually fixing permissions (if nothing else works)
Manually assigns group ownership to kvm and sets permissions to allow group members read/write access.
sudo chown root:kvm /dev/kvm
sudo chmod 660 /dev/kvm
This setup ensures that your system is ready for hardware-accelerated Android Emulator execution, especially on a clean Ubuntu install used for AOSP development.
Finally, run this command:
emulator
