Page Summary
-
This document guides you through building Cobalt with evergreen enabled and running the API on an Android device, after first completing the workstation and developer tool setups.
-
The process involves downloading the source code, setting up the build environment, downloading the Starboard toolchain and Android SDK, and installing necessary Linux packages.
-
You must create output directories for evergreen, select and download pre-built Cobalt binaries from GitHub, and then copy the files to the appropriate directories.
-
The instructions provide steps to compile an Android APK using Ninja, including building the Crashpad handler and loader_app, and then deploying and launching the APK on an Android device.
-
The document details how to build and run nplb (native platform library) tests, including generating test results in XML format, along with debugging tips and how to remove the Cobalt Android environment.
These instructions explain how to build and run Cobalt for the AOSP platform (aosp-arm, aosp-arm64, aosp-x86).
Before following these instructions, make sure you have set up your workstation and source checkout as described in Set up your environment - Linux.
Prerequisites
Follow all steps in Set up your environment - Linux to install basic system dependencies,
depot_tools, clone the Cobalt repository, and runbuild/install-build-deps.sh.Ensure your root
.gclientfile includesandroidintarget_os:target_os = [ 'linux', 'android' ]Then synchronize dependencies from your top-level repository:
cd ~/cobalt/src gclient syncSet up an Android debug keystore required for signing development APKs:
keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
Build and Run Cobalt for AOSP
Configure the build directory for the target AOSP platform (
aosp-arm,aosp-arm64,aosp-x86) usingcobalt/build/gn.py.Use the
-cflag to specify abuild_type(debug,devel,qa, orgold).cobalt/build/gn.py -p aosp-arm -c devel --no-rbeCompile the
cobalt_loadertarget usingautoninja:autoninja -C out/aosp-arm_devel cobalt_loaderThis generates the application loader APK at
out/aosp-arm_devel/apks/cobalt.apk.Deploy and launch on an AOSP device or emulator:
Ensure your device is connected via ADB (
adb devicesoradb connect <device_ip>:5555).Install the compiled APK:
adb install -r out/aosp-arm_devel/apks/cobalt.apkLaunch the application using
adb(Package:dev.cobalt.coat, Activity:dev.cobalt.app.MainActivity):adb shell am start dev.cobalt.coat/dev.cobalt.app.MainActivityPass runtime flags using
--esa commandLineArgs:adb shell am start --esa commandLineArgs 'url=https://www.youtube.com/tv' dev.cobalt.coat/dev.cobalt.app.MainActivityTo force-stop any running instance before relaunching:
adb shell am force-stop dev.cobalt.coat
Running Tests
The No Platform Left Behind (NPLB) test suite verifies Starboard implementation on AOSP targets.
Compile the NPLB test suite:
cobalt/build/gn.py -p aosp-arm -c devel --no-rbe autoninja -C out/aosp-arm_devel nplb_loaderThis generates the test APK at
out/aosp-arm_devel/apks/nplb.apk.Install the NPLB test APK on the target device:
adb install -r out/aosp-arm_devel/apks/nplb.apkLaunch NPLB on device passing the target compressed library argument via
--esa commandLineArgs:adb shell "am start --esa commandLineArgs '--evergreen_library=app/cobalt/lib/libnplb.lz4,--evergreen_content=app/cobalt/content' dev.cobalt.coat/dev.cobalt.app.MainActivity"Pass standard Google Test filtering arguments:
# Run NPLB with a specific test filter (e.g. Memory tests) adb shell "am start --esa commandLineArgs '--evergreen_library=app/cobalt/lib/libnplb.lz4,--evergreen_content=app/cobalt/content,--gtest_filter=*Memory*' dev.cobalt.coat/dev.cobalt.app.MainActivity"
Debugging
To monitor log output, watch logcat with a filter for Starboard and Cobalt messages:
adb logcat -s "starboard:*" "Cobalt:*"
Clean up or reset the environment
To clean build artifacts:
gn clean out/aosp-arm_devel