[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-24。"],[],[],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"]]