Please follow instructions below to build Android example apps with MediaPipe Framework.
To learn more about these example apps, start from Hello World! on
Android.
Building Android example apps with Bazel
Prerequisite
Install MediaPipe Framework following these instructions.
Setup Java Runtime.
Setup Android SDK release 35.0.0 or later.
Setup Android NDK version 28 or later.
MediaPipe recommends setting up Android SDK and NDK via Android Studio (and see
below for Android Studio setup). However, if you prefer using MediaPipe without
Android Studio, please run
setup_android_sdk_and_ndk.sh
to download and setup Android SDK and NDK before building any Android example
apps.
If Android SDK and NDK are already installed (e.g., by Android Studio), set
$ANDROID_HOME and $ANDROID_NDK_HOME to point to the installed SDK and NDK.
In order to use Framework on earlier Android versions, MediaPipe needs to switch
to a lower Android API level. You can achieve this by specifying api_level =
$YOUR_INTENDED_API_LEVEL in android_ndk_repository() and/or
android_sdk_repository() in the
WORKSPACE file.
To build an Android example app, build against the corresponding
android_binary build target. For instance, for MediaPipe Hands the target
is handtrackinggpu in the
BUILD
file:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-09 UTC."],[],[],null,["# MediaPipe Framework on Android\n\nPlease follow instructions below to build Android example apps with MediaPipe Framework.\nTo learn more about these example apps, start from [Hello World! on\nAndroid](./hello_world_android.md).\n\nBuilding Android example apps with Bazel\n----------------------------------------\n\n### Prerequisite\n\n- Install MediaPipe Framework following these [instructions](./install.md).\n- Setup Java Runtime.\n- Setup Android SDK release 35.0.0 or later.\n- Setup Android NDK version 28 or later.\n\nMediaPipe recommends setting up Android SDK and NDK via Android Studio (and see\nbelow for Android Studio setup). However, if you prefer using MediaPipe without\nAndroid Studio, please run\n[`setup_android_sdk_and_ndk.sh`](https://github.com/google/mediapipe/blob/master/setup_android_sdk_and_ndk.sh)\nto download and setup Android SDK and NDK before building any Android example\napps.\n\nIf Android SDK and NDK are already installed (e.g., by Android Studio), set\n`$ANDROID_HOME` and `$ANDROID_NDK_HOME` to point to the installed SDK and NDK. \n\n export ANDROID_HOME=\u003cpath to the Android SDK\u003e\n export ANDROID_NDK_HOME=\u003cpath to the Android NDK\u003e\n\nand add `android_ndk_repository()`, `android_sdk_repository()` and `bind()`\nrules into the\n[`WORKSPACE`](https://github.com/google/mediapipe/blob/master/WORKSPACE) file as\nthe following: \n\n $ echo \"android_sdk_repository(name = \\\"androidsdk\\\")\" \u003e\u003e WORKSPACE\n $ echo \"android_ndk_repository(name = \\\"androidndk\\\", api_level=26)\" \u003e\u003e WORKSPACE\n $ echo \"bind(name = \\\"android/crosstool\\\", actual = \\\"@androidndk//:toolchain\\\")\" \u003e\u003e WORKSPACE\n\nIn order to use Framework on earlier Android versions, MediaPipe needs to switch\nto a lower Android API level. You can achieve this by specifying `api_level =\n$YOUR_INTENDED_API_LEVEL` in android_ndk_repository() and/or\nandroid_sdk_repository() in the\n[`WORKSPACE`](https://github.com/google/mediapipe/blob/master/WORKSPACE) file.\n| **Tip:** You can run this [script](https://github.com/google/mediapipe/blob/master/build_android_examples.sh) to build (and install) all MediaPipe Android example apps.\n\n1. To build an Android example app, build against the corresponding\n `android_binary` build target. For instance, for MediaPipe Hands the target\n is `handtrackinggpu` in the\n [BUILD](https://github.com/google/mediapipe/tree/master/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/BUILD)\n file:\n\n **Note:** To reduce the binary size, consider appending `--linkopt=\"-s\"` to the command below to strip symbols. \n\n bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu\n\n2. Install it on a device with:\n\n adb install bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/handtrackinggpu.apk"]]