For Developers‎ > ‎How-Tos‎ > ‎

Run Mojo Shell

On Android


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.

Environment setup:
  1. Configure your working copy to build Android binaries.
  2. Build for android: gn --android build --android
  1. Ensure your device is running Lollipop and has an userdebug build.
Development Workflow

Build and install the Mojo Shell APK, and run it with the Sample App.
  1. Build changed files:
    • build --android
  2. Push mojo_shell to to your device:
    • adb install -r out/android_Debug/apks/MojoShell.apk
  3. Run Mojo Shell on the device:
    • ./mojo/tools/ mojo:sample_app
  4. If you get a crash you won't see symbols. Use tools/android_stack_parser/stack to map back to symbols, eg:
    • adb logcat | ./tools/android_stack_parser/stack

Linux & Windows

  1. Build the mojo target, which builds the shell and all examples:
    • ninja -C out/Release mojo
  2. Run Mojo Shell:
    • ./out/Release/mojo_shell mojo:sample_app
  3. Optional: Run Mojo Shell with an HTTP server
    • cd out/Release
    • python -m SimpleHTTPServer 4444 & 
    • ./mojo_shell --origin= --disable-cache mojo:mojo_sample_app
Development Workflow
  1. Run gyp whenever you modify .gyp or .gypi files.
    • ./mojo/tools/ --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.
  2. Build mojo-related targets.
    • ./mojo/tools/ --release build
  3. Run (most) mojo-related tests.
    • ./mojo/tools/ --release test
  4. Run mojo Python tests.
    • ./mojo/tools/ --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.)
  5. Run the Java tests:
    • Configure your working copy to build Android binaries.
    • Build the mojo tests:
      • ninja -C out/Release mojo_test_apk
    • Run the tests:
      • ./build/android/ instrumentation --test-apk MojoTest --test_data bindings:mojo/public/interfaces/bindings/tests/data
  6. If you're modifying the build, be sure to also update and test the GN build.
    • gn gen out/GN
    • ninja -C out/GN mojo
    • ./mojo/tools/ mojo/tools/data/unittests out/GN