@@ -16,12 +16,14 @@ nav_order: 1
16
16
17
17
Please follow instructions below to build Android example apps in the supported
18
18
MediaPipe [ solutions] ( ../solutions/solutions.md ) . To learn more about these
19
- example apps, start from [ Hello World! on Android] ( ./hello_world_android.md ) . To
20
- incorporate MediaPipe into an existing Android Studio project, see these
21
- [ instructions] ( ./android_archive_library.md ) that use Android Archive (AAR) and
22
- Gradle.
19
+ example apps, start from [ Hello World! on Android] ( ./hello_world_android.md ) .
23
20
24
- ## Building Android example apps
21
+ To incorporate MediaPipe into Android Studio projects, see these
22
+ [ instructions] ( ./android_solutions.md ) to use the MediaPipe Android Solution
23
+ APIs (currently in alpha) that are now available in
24
+ [ Google's Maven Repository] ( https://maven.google.com/web/index.html?#com.google.mediapipe ) .
25
+
26
+ ## Building Android example apps with Bazel
25
27
26
28
### Prerequisite
27
29
@@ -51,16 +53,6 @@ $YOUR_INTENDED_API_LEVEL` in android_ndk_repository() and/or
51
53
android_sdk_repository() in the
52
54
[ ` WORKSPACE ` ] ( https://github.com/google/mediapipe/blob/master/WORKSPACE ) file.
53
55
54
- Please verify all the necessary packages are installed.
55
-
56
- * Android SDK Platform API Level 28 or 29
57
- * Android SDK Build-Tools 28 or 29
58
- * Android SDK Platform-Tools 28 or 29
59
- * Android SDK Tools 26.1.1
60
- * Android NDK 19c or above
61
-
62
- ### Option 1: Build with Bazel in Command Line
63
-
64
56
Tip: You can run this
65
57
[ script] ( https://github.com/google/mediapipe/blob/master/build_android_examples.sh )
66
58
to build (and install) all MediaPipe Android example apps.
@@ -84,108 +76,3 @@ to build (and install) all MediaPipe Android example apps.
84
76
` ` ` bash
85
77
adb install bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/handtrackinggpu.apk
86
78
` ` `
87
-
88
- # ## Option 2: Build with Bazel in Android Studio
89
-
90
- The MediaPipe project can be imported into Android Studio using the Bazel
91
- plugins. This allows the MediaPipe examples to be built and modified in Android
92
- Studio.
93
-
94
- To incorporate MediaPipe into an existing Android Studio project, see these
95
- [instructions](./android_archive_library.md) that use Android Archive (AAR) and
96
- Gradle.
97
-
98
- The steps below use Android Studio 3.5 to build and install a MediaPipe example
99
- app:
100
-
101
- 1. Install and launch Android Studio 3.5.
102
-
103
- 2. Select ` Configure` -> ` SDK Manager` -> ` SDK Platforms` .
104
-
105
- * Verify that Android SDK Platform API Level 28 or 29 is installed.
106
- * Take note of the Android SDK Location, e.g.,
107
- ` /usr/local/home/Android/Sdk` .
108
-
109
- 3. Select ` Configure` -> ` SDK Manager` -> ` SDK Tools` .
110
-
111
- * Verify that Android SDK Build-Tools 28 or 29 is installed.
112
- * Verify that Android SDK Platform-Tools 28 or 29 is installed.
113
- * Verify that Android SDK Tools 26.1.1 is installed.
114
- * Verify that Android NDK 19c or above is installed.
115
- * Take note of the Android NDK Location, e.g.,
116
- ` /usr/local/home/Android/Sdk/ndk-bundle` or
117
- ` /usr/local/home/Android/Sdk/ndk/20.0.5594570` .
118
-
119
- 4. Set environment variables ` $ANDROID_HOME ` and ` $ANDROID_NDK_HOME ` to point
120
- to the installed SDK and NDK.
121
-
122
- ` ` ` bash
123
- export ANDROID_HOME=/usr/local/home/Android/Sdk
124
-
125
- # If the NDK libraries are installed by a previous version of Android Studio, do
126
- export ANDROID_NDK_HOME=/usr/local/home/Android/Sdk/ndk-bundle
127
- # If the NDK libraries are installed by Android Studio 3.5, do
128
- export ANDROID_NDK_HOME=/usr/local/home/Android/Sdk/ndk/< version number>
129
- ` ` `
130
-
131
- 5. Select ` Configure` -> ` Plugins` to install ` Bazel` .
132
-
133
- 6. On Linux, select `File` -> ` Settings` -> ` Bazel settings` . On macos, select
134
- ` Android Studio` -> ` Preferences` -> ` Bazel settings` . Then, modify ` Bazel
135
- binary location` to be the same as the output of ` $ which bazel` .
136
-
137
- 7. Select ` Import Bazel Project` .
138
-
139
- * Select ` Workspace` : ` /path/to/mediapipe` and select `Next`.
140
- * Select ` Generate from BUILD file` : ` /path/to/mediapipe/BUILD` and select
141
- ` Next` .
142
- * Modify ` Project View` to be the following and select `Finish`.
143
-
144
- ` ` `
145
- directories:
146
- # read project settings, e.g., .bazelrc
147
- .
148
- -mediapipe/objc
149
- -mediapipe/examples/ios
150
-
151
- targets:
152
- //mediapipe/examples/android/...:all
153
- //mediapipe/java/...:all
154
-
155
- android_sdk_platform: android-29
156
-
157
- sync_flags:
158
- --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
159
- ` ` `
160
-
161
- 8. Select ` Bazel` -> ` Sync` -> ` Sync project with Build files` .
162
-
163
- Note: Even after doing step 4, if you still see the error: ` " no such package
164
- '@androidsdk//': Either the path attribute of android_sdk_repository or the
165
- ANDROID_HOME environment variable must be set." ` , please modify the
166
- [` WORKSPACE` ](https://github.com/google/mediapipe/blob/master/WORKSPACE)
167
- file to point to your SDK and NDK library locations, as below:
168
-
169
- ` ` `
170
- android_sdk_repository(
171
- name = " androidsdk" ,
172
- path = " /path/to/android/sdk"
173
- )
174
-
175
- android_ndk_repository(
176
- name = " androidndk" ,
177
- path = " /path/to/android/ndk"
178
- )
179
- ` ` `
180
-
181
- 9. Connect an Android device to the workstation.
182
-
183
- 10. Select ` Run...` -> ` Edit Configurations...` .
184
-
185
- * Select ` Templates` -> ` Bazel Command` .
186
- * Enter Target Expression:
187
- ` //mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu`
188
- * Enter Bazel command: ` mobile-install` .
189
- * Enter Bazel flags: ` -c opt --config=android_arm64` .
190
- * Press the ` [+]` button to add the new configuration.
191
- * Select ` Run` to run the example app on the connected Android device.
0 commit comments