Before you start, you'll need a device with an unlocked bootloader, otherwise you won't be able to run adb root (or any of the commands that require root). For Googlers, follow this link
and follow the instructions before returning to this page.
mojob.py build --android
- Ensure your device is running Lollipop and has an userdebug build.
Build and install the Mojo Shell APK, and run it with the Sample App.
Push mojo_shell to to your device:
- Build changed files:
Run Mojo Shell on the device:
- adb install -r out/android_Debug/apks/MojoShell.apk
If you get a crash you won't see symbols. Use tools/android_stack_parser/stack to map back to symbols, eg:
- ./mojo/tools/android_mojo_shell.py mojo:sample_app
- adb logcat | ./tools/android_stack_parser/stack
Linux & Windows
- Build the mojo target, which builds the shell and all examples:
Run Mojo Shell:
- ninja -C out/Release mojo
Optional: Run Mojo Shell with an HTTP server
- ./out/Release/mojo_shell mojo:sample_app
- cd out/Release
- python -m SimpleHTTPServer 4444 &
- ./mojo_shell --origin=http://127.0.0.1:4444 --disable-cache mojo:mojo_sample_app
- Run gyp whenever you modify .gyp or .gypi files.
Build mojo-related targets.
- ./mojo/tools/mojob.sh --static gyp
- You may also want to do this after syncing the repo, because the following script will ignore any GYP_DEFINES in your environment and put you in a known state.
Run (most) mojo-related tests.
- ./mojo/tools/mojob.sh --release build
Run mojo Python tests.
- ./mojo/tools/mojob.sh --release test
Run the Java tests:
- ./mojo/tools/mojob.sh --release pytest
- the Python tests are incomplete (the bindings tests are not run) if you do a component build (i.e. forgot to pass --static in first step, or directly invoked GYP with GYP_DEFINES=component=shared_library.)
If you're modifying the build, be sure to also update and test the GN build.
- Configure your working copy to build Android binaries.
- Build the mojo tests:
- ninja -C out/Release mojo_test_apk
- Run the tests:
- ./build/android/test_runner.py instrumentation --test-apk MojoTest --test_data bindings:mojo/public/interfaces/bindings/tests/data
- gn gen out/GN
- ninja -C out/GN mojo
- ./mojo/tools/test_runner.py mojo/tools/data/unittests out/GN