tree: 3ac8a0839f4d7ed399478445ac2a0b2084840e8e [path history] [tgz]
  1. App/
  2. third_party/
  3. .gn
  4. args.gni
  5. BUILD.gn
  6. README.md
examples/tv-casting-app/android/README.md

Matter TV Casting Android App Example

This is a Matter TV Casting Android app that can be used to cast content to a TV. This app discovers TVs on the local network that act as commissioners, lets the user select one, sends the TV a User Directed Commissioning request, enters commissioning mode, advertises itself as a Commissionable Node and gets commissioned. Then it allows the user to send Matter ContentLauncher commands to the TV.

Requirements for building

Refer to this file to download the recommended version for the Android SDK and NDK for your machine. Set the $ANDROID_HOME environment variable to where the SDK is downloaded and the $ANDROID_NDK_HOME environment variable to point to where the NDK package is downloaded.

export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_NDK_HOME=~/Library/Android/sdk/ndk/{NDK_VERSION_NUMBER}

ABIs and TARGET_CPU

TARGET_CPU can have the following values, depending on your smartphone CPU architecture:

ABITARGET_CPU
armeabi-v7aarm
arm64-v8aarm64
x86x86
x86_64x64

Gradle & JDK Version

We are using Gradle 7.1.1 for all android project which does not support Java 17 (https://docs.gradle.org/current/userguide/compatibility.html) while the default JDK version on MacOS for Apple Silicon is ‘openjdk 17.0.1’ or above.

Using JDK bundled with Android Studio will help with that.

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home/

Preparing for build

Complete the following steps to prepare the Matter build:

  1. Check out the Matter repository.

  2. Run bootstrap (only required first time)

    source scripts/bootstrap.sh
    

Building & Installing the app

This is the simplest option. In the command line, run the following command from the top Matter directory:

./scripts/build/build_examples.py --target android-arm64-tv-casting-app build

(To build this app with no debugging hooks, use the android-arm64-tv-casting-app-no-debug target)

See the table above for other values of TARGET_CPU.

The debug Android package app-debug.apk will be generated at out/android-$TARGET_CPU-tv-casting-app/outputs/apk/debug/, and can be installed with

adb install out/android-$TARGET_CPU-tv-casting-app/outputs/apk/debug/app-debug.apk

You can use Android Studio to edit the Android app itself and run it after build_examples.py, but you will not be able to edit Matter Android code from src/controller/java, or other Matter C++ code within Android Studio.