页面简介
"Build and run MediaPipe Framework C++ and GPU perception graphs on Android devices with Bazel, ADB, and CameraX."
正文摘录
Home Products Google AI Edge MediaPipe Send feedback MediaPipe Framework on Android 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 Set up your local toolchain and compile MediaPipe Android APKs from the command line 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. export ANDROID_HOME=<path to the Android SDK> export ANDROID_NDK_HOME=<path to the Android NDK> and add android_ndk_repository(), android_sdk_repository() and bind() rules into the WORKSPACE file as the following: $ echo "android_sdk_repository(name = \"androidsdk\")" >> WORKSPACE $ echo "android_ndk_repository(name = \"androidndk\", api_level=26)" >> WORKSPACE $ echo "bind(name = \"android/crosstool\", actual = \"@androidndk//:toolchain\")" >> WORKSPACE 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: bazel build -c opt --config=android_arm64 \ mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu Install it on a device with: adb install \ bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/handtrackinggpu.apk Send feedback Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Last updated 2026-11-09 UTC.