This document describes how to get started with emulator development under linux.
The instructions here assume you are using a deb based distribution, such as Debian, Ubuntu or Goobuntu.
Install the following dependencies:
sudo apt-get install -y git build-essential python qemu-kvm ninja-build python-pip ccache
We need python to run the scripts, kvm to be able to run the emulator and git to get the source.
First we need to obtain the repo tool.
mkdir $HOME/bin curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > $HOME/bin/repo chmod 700 $HOME/bin/repo
Make sure to add $HOME/bin
to your path, if it is not already there.
export PATH=$PATH:$HOME/bin
Do not forget to add this to your .bashrc
file.
You can initialize repo as follows:
mkdir -p emu-master-dev && cd emu-master-dev repo init -u https://android.googlesource.com/platform/manifest -b emu-master-dev
Note: You could use persistent-https to initialize the repo, this might give you slightly better performance if your have the persistent-https git plugin.
Sync the repo (and get some coffee, or a have a good nap.)
repo sync -j 8
Congratulations! You have all the sources you need. Now run:
cd external/qemu && android/rebuild.sh
If all goes well you should have a freshly build emulator in the objs
directory.
You can pass the flag --help
to the rebuild script to get an idea of which options you can pass in.
The rebuild script does a complete clean build. You can use ninja to partial builds:
ninja -C objs
It is highly recommended to install the ‘ccache’ build tool on your development machine(s). The Android emulator build scripts will probe for it and use it if available, which can speed up incremental builds considerably.
sudo apt-get install ccache
Configure ccache to use a different cache size with ccache -M <max size>
. You can see a list of configuration options by calling ccache alone. * The default ccache directory is ~/.ccache. You might want to symlink it to another directory (for example, when using FileVault for your home directory). You should make this large if you are planning to cross compile to many targets (ming/windows).
It is highly recommended to use a windows machine for windows development, vs cross compilation.
It is possible to cross compile from linux to windows. This is mainly useful to quickly discover compilation issues, as you will not be able to actually run the code.
The windows target requires you to install the MSVC libraries. These libraries need manual intervention to be installed on your linux machine as you will need to:
run:
$AOSP/external/qemu/android/scripts/activate-msvc.sh
This script will guide you through the steps, and configure your machine for cross compiling msvc. Once this is completed you should be able to replicate what is happening on the build bots. The script will require sudo priveleges
If all went well you can now target windows as follows:
cd $AOSP/external/qemu/ && ./android/rebuild.sh --target windows
Strongly consider not doing this, and develop on a windows machine.
You will need to have access to a Windows machine.
Package your Windows SDK installation into a zip file by running the following on a Windows machine:
cd path/to/depot_tools/win_toolchain # customize the Windows SDK version numbers python package_from_installed.py 2017 -w 10.0.17134.0
export DISK_LOC=/mnt/jfs_msvc.img # Make sure we have JFS sudo apt-get install -y jfsutils sudo mkdir -p /mnt/msvc # Create a OS/2 case insensitive loopback fs. echo "Creating empty img in /tmp/jfs.img" dd if=/dev/zero of=/tmp/jfs.img bs=1M count=4096 chmod a+rwx /tmp/jfs.img echo "Making filesystem" mkfs.jfs -q -O /tmp/jfs.img sudo mv /tmp/jfs.img ${DISK_LOC} sudo mount ${DISK_LOC} /mnt/msvc -t jfs -o loop sudo chmod a+rwx /mnt/msvc unzip msvc_zip -D /mnt/msvc
If all went well you can now target windows as follows:
./android/rebuild.sh --target windows
It is higly recommended to use a mac for mac development, vs cross compilation.
It is possible to cross compile from linux to mac os. This is mainly useful to quickly discover compilation issues, as you will not be able to actually run the code.
The windows target requires you to install the a cross compilers. These libraries need manual intervention to be installed on your linux machine. You will need to obtain a xcode.xip with MacOS-SDK (10.13-10.15) (Xcode 11.3 has been tested). You can obtain it from go/xcode if you're within Google or from Apple.
Once you have obtained the .xip you can create the toolchain as follows:
./android/scripts/unix/activate-darwin-cross.sh --xcode=/data/.../Xcode_11.3.xip
After that succeeds you should be able to target darwin:
./android/rebuild.sh --target darwin
Here you can find details on submitting patches. No external configuation should be needed if you are within Google.