Skip to content

The easiest way to build Android CHIPTool app

Filip Jagodziński edited this page Mar 25, 2021 · 2 revisions
  1. Move to the root of connectedhomeip project.

  2. Run a Docker container with CHIP source dir mounted in /home/connectedhomeip. If the image is not available locally, Docker will fetch one for you.

    • If you are fine with the container polluting your source dir with build artifacts use:

      $ docker run --interactive --tty --rm --volume "$PWD:/home/connectedhomeip" --workdir "/home/connectedhomeip" connectedhomeip/chip-build-android bash
    • If you want to keep your source dir clean, you can mount the volume as readonly:

      $  docker run --privileged --interactive --tty --rm --volume "$PWD:/home/connectedhomeip-ro:ro" connectedhomeip/chip-build-android bash

      and then use an overlay:

      $ mkdir -p /tmp/overlay /home/connectedhomeip
      $ mount -t tmpfs tmpfs /tmp/overlay
      $ mkdir -p /tmp/overlay/{upper,work}
      $ mount -t overlay overlay -o lowerdir=/home/connectedhomeip-ro,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work /home/connectedhomeip
      $ cd /home/connectedhomeip
  3. Accept all Android SDK licenses.

    $ yes | "$ANDROID_HOME"/tools/bin/sdkmanager --licenses
  4. Bootstrap the environment.

    $ ./scripts/build/gn_bootstrap.sh
  5. Build CHIP libs. You can choose from arm, arm64, x86 or x64 target CPU arch.

    $ TARGET_CPU="arm64" ./scripts/examples/android_app.sh
  6. Build CHIPTool app.

    $ pushd src/android/CHIPTool/; ./gradlew build; popd

The apk files (debug and release) are available in src/android/CHIPTool/app/build/outputs/apk/.