Ask questionsBazel build failed in Android Studio
Hi, I followed the installation instruction of "Setting up Android Studio with MediaPipe". When I imported the bazel project, bazel build failed in Android Studio.
Android Studio: 3.5 SDK Platform 28 NDK 20.0.5594570 SDK Tools 26.1.1 SDK Platform-Tools 29.0.2 SDK Build-Tools 28.0.3
The following are the errors reported in the Bazel Console in Android Studio: ERROR: /private/var/tmp/_bazel_junyaoguo/fd64e915985bd32c3dd281a6a4d37a1c/external/androidsdk/BUILD.bazel:8:1: in @intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect aspect on android_sdk rule @androidsdk//:sdk-28: Traceback (most recent call last): File"/private/var/tmp/_bazel_junyaoguo/fd64e915985bd32c3dd281a6a4d37a1c/external/androidsdk/BUILD.bazel", line 8 @intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect(...)
File"/private/var/tmp/_bazel_junyaoguo/fd64e915985bd32c3dd281a6a4d37a1c/external/intellij_aspect/intellij_info_bundled.bzl", line 54, in _aspect_impl intellij_info_aspect_impl(target, ctx, semantics)
File"/private/var/tmp/_bazel_junyaoguo/fd64e915985bd32c3dd281a6a4d37a1c/external/intellij_aspect/intellij_info_impl.bzl", line 896, in intellij_info_aspect_impl collect_android_sdk_info(ctx, ide_info, ide_info_file, output_g...)
File"/private/var/tmp/_bazel_junyaoguo/fd64e915985bd32c3dd281a6a4d37a1c/external/intellij_aspect/intellij_info_impl.bzl", line 743, in collect_android_sdk_info
list(ctx.rule.attr.android_jar.files)
type 'depset' is not iterable. Use the to_list() method to get a list. Use --incompatible_depset_is_not_iterable=false to temporarily disable this check.
ERROR: /Users/junyaoguo/Documents/SVL_Projects/mediapipe/mediapipe/java/com/google/mediapipe/components/BUILD:60:1: no such package 'third_party/java/jsr305_annotations': BUILD file not found in any of the following directories.

Also, I can't run the example on Android phone as instructed in the last step (step 8) in the installation manual. Could you please take a look?Thanks.
Answer
questions
jiuqiant
For the build error, the error message suggests that you need to append --incompatible_depset_is_not_iterable=false to the build command.
Please do
$ bazel clean --expunge
$ bazel build -c opt --config=android_arm64 --incompatible_depset_is_not_iterable=false mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu
I also recommend that you keep the version of your SDK Platform, SDK Platform-Tools, and SDK Build-Tools in sync, either 28 or 29.
Moreover, can you report what error you encounter in step 8?
Related questions