This document describes how to make local builds of the Android bindings in this repository. Most consumers of these bindings do not need to follow this process, but will instead use pre-built bindings.
Typically, this process only needs to be run once, although periodically you may need to repeat some steps (e.g., rust updates should be done periodically)
At the end of this process you should have the following environment variables set up.
The easiest way to install all the dependencies (and automatically handle updates), is by using Android Studio. Once this is installed, it must be run and the Glean project opened to complete initial setup. If Android Studio asks you to upgrade the version of Gradle, decline.
The following dependencies can be installed in Android Studio through
Tools > SDK Manager > SDK Tools:
- Android SDK Tools (may already be selected)
- NDK r20
With the dependencies installed, note down the
Android SDK Location in
Tools > SDK Manager.
ANDROID_HOME environment variable to that path.
ANDROID_NDK_ROOT can be set to
JAVA_HOME to be the location of Android Studio's JDK which can be found in Glean's "Project Structure" menu. (You may need to escape spaces in the path).
If you want to install the NDK manually:
- Download NDK r20 from https://developer.android.com/ndk/downloads.
- Extract it and put it somewhere (
$HOME/.android-ndk-r20is a reasonable choice, but it doesn't matter).
ANDROID_NDK_ROOTto this path.
ANDROID_NDK_ROOT, for compatibility with some android Gradle plugins.
Rust can be installed using
rustup, with the following commands:
curl https://sh.rustup.rs -sSf | sh
Platform specific toolchains need to be installed for Rust. This can be
done using the
rustup target command. In order to enable building to real
devices and Android emulators, the following targets need to be installed:
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi
rustup target add i686-linux-android
rustup target add x86_64-linux-android
This should be relatively straightforward and painless:
Ensure your repository is up-to-date.
Ensure Rust is up-to-date by running
The builds are all performed by
./gradlewand the general syntax used is
You can see a list of projects by executing
./gradlew projectsand a list of tasks by executing
The above can be skipped if using
Android Studio. The project directory can be imported
and all the build details can be left to the IDE.
Q: Android Studio complains about Python not being found when building.
A: Make sure that the
pythonbinary is on your
PATH. On Windows, in addition to that, it might be required to add its full path to the
Q: Android Studio complains about
Toolchain for X does not exist.
A: On Windows, make sure that the
$project_root/local.propertiespoints to an existing directory containing the Android NDK.