Skip to content

Compare: Building for Android

Showing with 28 additions and 16 deletions.
  1. +28 −16 Building-for-Android.md
@@ -1,10 +1,36 @@
## Get Android tools

## Set up toolchain
After cloning the repository and [installing dependencies common to all targets](https://github.com/servo/servo#setting-up-your-environment), this should obtain the Android-specific tools:

```sh
./mach bootstrap-android
```

## Build Servo

After that, in some sub-commands the `--android` flag is short for `--target armv7-linux-androideabi`

```sh
# Replace "--release" with "--dev" to create an unoptimized debug build.
./mach build --release --android
./mach package --release --android
```

For running in an emulator however, you’ll likely want to build for Android x86 instead:

```sh
./mach build --release --target i686-linux-android
./mach package --release --target i686-linux-android
```

## Set up toolchain manually

If `./mach bootstrap-android` does not work or is not appropriate, the Android tools can be installed manually.

First, we need the Android SDK and NDK and associated development tools:

- The Android NDK can be downloaded from https://developer.android.com/ndk/downloads/older_releases.html#ndk-12b-downloads
- The Android SDK can be downloaded from http://developer.android.com/sdk/index.html
- The Android SDK can be downloaded from https://developer.android.com/studio/, near “Command line tools only” at the bottom.

To install the NDK and SDK, refer to the guidelines on the website. When you install the SDK, run the UI tool at `tools/android` (on Mac, this would be under /Users/\<username\>/Library/Android/sdk) and update the SDK in order to install a full set of Android libraries. You may use the Android-18 platform. From the commandline, you may also do:
```sh
@@ -37,20 +63,6 @@ If you're on OSX, install these packages:
brew install nspr ant
```

## Build Servo

```sh
git clone https://github.com/mozilla/servo.git
cd servo
# Make sure these env vars are set:
export ANDROID_NDK="/path/to/ndk"
# Replace "--release" with "--dev" to create an unoptimized debug build.
./mach build --release --android
./mach package --release --android
```

## Installing and running on-device

To install Servo on a hardware device, first [set up your device for development](https://developer.android.com/tools/device.html).
You can’t perform that action at this time.