diff --git a/docs/building.md b/docs/building.md index 6a0cd14475..ea24e44b03 100644 --- a/docs/building.md +++ b/docs/building.md @@ -100,20 +100,25 @@ The following instructions assume that you are building `application-services` f [Fenix Auto-publication workflow for android-components and application-services](howtos/locally-published-components-in-fenix.md). 1. Install Android SDK, JAVA, NDK and set required env vars - 1. Clone the [firefox-android](https://github.com/mozilla-mobile/firefox-android) repository (**not** inside the Application Service repository). - 1. Install [Java **17**](https://www.oracle.com/java/technologies/downloads/#java17) for your system - 1. Set `JAVA_HOME` to point to the JDK 17 installation directory. + 1. [Bootstrap a Firefox for Android environment](https://firefox-source-docs.mozilla.org/mobile/android/index.html) (**not** inside the Application Service repository). 1. Download and install [Android Studio](https://developer.android.com/studio/#downloads). - 1. Set `ANDROID_SDK_ROOT` and `ANDROID_HOME` to the Android Studio sdk location and add it to your rc file (either `.zshrc` or `.bashrc` depending on the shell you use for your terminal). - 1. Configure the required versions of NDK - `Configure menu > System Settings > Android SDK > SDK Tools > NDK > Show Package Details > NDK (Side by side)` - - 29.0.14206865 (required by Application Services, [as configured](https://github.com/mozilla/application-services/blob/main/build.gradle#L33)) + 1. Configure Android Studio to use the bootstrapped SDK under `Settings > Languages & Frameworks > Android SDK`, set it to the SDK from mozbuild. Ex: `~/.mozbuild/android-sdk-linux` or `~/.mozbuild/android-sdk-macos` + 1. Download the required NDK and command-line tools under `Settings > Languages & Frameworks > Android SDK > SDK Tools`. Pick: + 1. NDK (Side by side) version 29.0.14206865 [as configured](https://github.com/mozilla/application-services/blob/bb8cde8a5/taskcluster/docker/linux/Dockerfile#L25) + 1. Android SDK Command-line Tools (latest) + 1. Set environment variables based on the boostrapped code and the downloaded NDK. Add it to your rc file (either `.zshrc` or `.bashrc` depending on your shell) to make it permanent + 1. Set `JAVA_HOME` to point to the bootstraped JDK 17 installation directory. Ex: `export JAVA_HOME=~/.mozbuild/jdk/jdk-17.0.18+8/` + 1. Set `ANDROID_HOME` to the bootstraped Android SDK. Ex: `export ANDROID_HOME=~/.mozbuild/android-sdk-linux` + 1. Set `NSS_STATIC` to 1. Ex: `export NSS_STATIC=1` + 1. Set `NSS_DIR` to your local NSS folder. Ex: `export NSS_DIR=~/Mozilla/application-services/libs/desktop/linux-x86-64/nss` + 1. Set `ANDROID_NDK_ROOT` to the NDK you downloaded via Android Studio, Ex: `export ANDROID_NDK_ROOT=~/.mozbuild/android-sdk-linux/ndk/29.0.14206865` 1. If you are on Windows using WSL - drop to the section below, [Windows setup for Android (WSL)](building.md#windows-setup-for-android-via-wsl) before proceeding. 1. Check dependencies, environment variables 1. Run `./libs/verify-android-environment.sh` 2. Follow instructions and rerun until it is successful. +**Note:** If you opened the application-services or Firefox repos in Android Studio, it likely added a `local.properties` or `gradle-daemon-jvm.properties` file that could override some of the environment variables above. If you experience build errors, correct or delete these values in the `local.properties` files. ### Windows setup for Android (via WSL) diff --git a/libs/android_defaults.sh b/libs/android_defaults.sh index 14bd1d8de4..f9eb8d4923 100755 --- a/libs/android_defaults.sh +++ b/libs/android_defaults.sh @@ -4,6 +4,7 @@ if [[ -z "${ANDROID_NDK_HOME:-}" || -z "${ANDROID_NDK_ROOT:-}" ]]; then pushd .. + echo "Initializing NDK. Can take a few seconds." NDK_VERSION=$(./gradlew -q printNdkVersion | tail -1) export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/$NDK_VERSION" export ANDROID_NDK_ROOT="$ANDROID_NDK_HOME"