This document describes how to develop and debug for Android.
The main entrypoint to Android's Java code is cordova-plugin-outline/android/java/org/outline/OutlinePlugin.java
💡 NOTE: To easiest way to get set up for Android on a new environment is to use
tools/build/setup_macos_android.shortools/build/setup_linux_android.sh.
Additional requirements for Android:
- Java Development Kit (JDK) 11
- Latest Android Sdk Commandline Tools (download)
- Place it at
$HOME/Android/sdk/cmdline-tools/latest
- Place it at
- Android SDK 30 (with build-tools) via commandline
$HOME/Android/sdk/cmdline-tools/latest/bin/sdkmanager "platforms;android-30" "build-tools;30.0.3"- Set up the environment:
export ANDROID_SDK_ROOT=$HOME/Android/sdk(ANDROID_HOMEis the recommendation, but Cordova wantsANDROID_SDK_ROOT)
- Set up the environment:
- Gradle 7.3+
- On macOS:
brew install gradle
- On macOS:
Android Studio 2020.3.1+ is not required, but it's helpful if you are developing Android code.
To build for android, run:
npm run action cordova/build androidMake sure to rebuild after modifying platform dependent files!
💡 NOTE: If this command ever gives you unexpected Cordova errors, try runnning
npm run resetfirst.
Cordova will generate a new Android project in the platforms/android directory. Install the built apk by platforms/android/app/build/outputs/apk/<processor>/debug/app-<processor>-debug.apk (You will need to find the corresponding <processor> architecture if you choose to install the apk on a device).
A Docker image with all pre-requisites for Android builds is included. To build:
- Install dependencies with
./tools/build/build.sh npm ci - Then build with
./tools/build/build.sh npm run action gulp -- build android
- Connect an Android device and enable USB debugging.
- Build the app, with
npm run action cordova/build android - From the project root, run:
adb install -r -d platforms/android/app/build/outputs/apk/<processor>/debug/app-<processor>-debug.apk
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 cordova_main.js
Using Android Studio
- Open existing project →
<root_project_dir>/platforms/android - Click on "Android Monitor" at the bottom
- Make sure
org.outline.android.clientis selected from the middle menu (it should not say "no debuggable processes")