This document describes how to develop and debug for Android.
The main entrypoint to Android's Java code is client/src/cordova/plugin/android/java/org/outline/OutlinePlugin.java
Install these pre-requisites:
-
Java Development Kit (JDK) 17+. On macOS:
brew install openjdk@17 # Make it visible to `java_home` sudo ln -sfn "$(realpath "$(brew --prefix)")/opt/openjdk@17/libexec/openjdk.jdk" /Library/Java/JavaVirtualMachines/openjdk-17.jdk export JAVA_HOME=$(/usr/libexec/java_home -v 17.0)
-
Gradle 8.14.2+. On macOS:
brew install gradle.
Then we need to install and configure the Android components. You can follow the Cordova Android Platform Guide, which uses Android Studio to configure the environment. You need an Android Studio compatible with the Android Gradle Plugin 8.10.1 (see build.gradle) we use (compatibility table).
Alternatively, you can do it on the command-line:
-
Set environmental variables:
export ANDROID_HOME=$HOME/Library/Android/sdk export ANDROID_NDK=$ANDROID_HOME/ndk
-
Install the Android command-line tools and make them available on the command line:
curl -o /tmp/commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-mac-13114758_latest.zip unzip /tmp/commandlinetools.zip -d /tmp mkdir -p "$ANDROID_HOME/cmdline-tools/latest" mv /tmp/cmdline-tools/* "$ANDROID_HOME/cmdline-tools/latest/" export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin/"
-
Install platform and build tools:
sdkmanager "platforms;android-36" "build-tools;36.0.0" "ndk;28.2.13676358"
The NDK version must match the
ndkVersionpin in build-extras.gradle, whose comment explains why we pin it (AGP uses it to strip the packaged native libraries). -
Install optional components that help development (source code, emulator and image):
sdkmanager "sources;android-36" "system-images;android-36;default;arm64-v8a"
Note: you will need the system-images;android-36;default;x86_64 image on an Intel computer.
For development of the OutlineAndroidLib, we recommend installing Android Studio. That also make it easier to create virtual devices and run the emulator.
You can check your environment with:
npm run action client/src/cordova/setup android
cd client
npx cordova requirements android| Component | version | constrained by | set in |
|---|---|---|---|
| Android API Level | 36+ | Play Store | config.xml, build.gradle |
| cordova-android | 15 | Android API Level | package.json |
| JDK | 17 | cordova-android | install instruction |
| Gradle | 8.14.2+ | cordova-android | gradle-wrapper.properties |
| Android Gradle Plugin (AGP) | 8.10.1 | cordova-android | build.gradle |
| Android Build Tools | 36.0.0+ | cordova-android | install instructions |
| Android NDK | 28.2.13676358 | native-lib stripping | build-extras.gradle, install instructions |
| Android Studio | 2025.1.1 (Narwhal) | AGP |
To build the app for Android, run:
npm run action client/src/cordova/build androidThe built apk will be at: client/platforms/android/app/build/outputs/apk/debug/app-debug.apk.
We also support passing a --verbose option on cordova android:
npm run action client/src/cordova/build android -- --verboseMake sure to rebuild after modifying platform dependent files!
💡 NOTE: If this command ever gives you unexpected Cordova errors, try runnning
npm run resetfirst.
-
Start the simulator or connect an Android device and enable USB debugging.
-
From the project root, run:
adb install -r -d client/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Alternatively, run with:
cd client
npx cordova run android -- --gradleArg=--include-build=../../src/cordova/android/OutlineAndroidLibOpen src/cordova/android/OutlineAndroidLib on Android Studio. That will allow you to leverage the IDE features (auto-complete, warnings, etc) and run unit tests easily.
This project represents a library that implements most of the Outline native functionality and does not depend on Cordova. That library is imported by the "app" module that is generated by Cordova. The only native Android code outside of this library is OutlinePlugin.java, which integrates with CordovaLib.
To make the entire application load properly on Android Studio, you need to edit the generated /client/platforms/android/settings.gradle and add:
includeBuild "../../src/cordova/android/OutlineAndroidLib"Run Outline on your phone with USB debugging enabled, then on Chrome:
- Go to chrome://inspect
- Find Outline
- Click inspect
- Open the Console
- Note that all TypeScript code is browserified in a single main.cordova.js
You can debug the Java code using logcat on Android Studio:
- Start the app
- Select the "Logcat" tab at the bottom
- Select
org.outline.android.clientin the middle menu (it should not say "no debuggable processes")
It's also possible to use the logcat command.