Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ body:
label: "[Android Only] Android Build Tools and NDK Version"
description: Required if the Target Platform is Android
placeholder: |
Build Tools: 30.0.2
NDK: 21.4.7075529
Build Tools: 35.0.0
NDK: 28.2.13676358

- type: input
id: ios_build_env
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/build-install-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ body:
label: "[Android Only] Android Build Tools and NDK Version"
description: Required if the Target Platform is Android
placeholder: |
Build Tools: 30.0.2
NDK: 21.4.7075529
Build Tools: 35.0.0
NDK: 28.2.13676358

- type: input
id: ios_build_env
Expand Down
13 changes: 11 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,22 @@ http_archive(
urls = ["https://github.com/abseil/abseil-cpp/archive//9687a8ea750bfcddf790372093245a1d041b21a3.tar.gz"],
)

http_archive(
name = "rules_android_ndk",
sha256 = "d230a980e0d3a42b85d5fce2cb17ec3ac52b88d2cff5aaf86bae0f05b48adc55",
strip_prefix = "rules_android_ndk-d5c9d46a471e8fcd80e7ec5521b78bb2df48f4e0",
url = "https://github.com/bazelbuild/rules_android_ndk/archive/d5c9d46a471e8fcd80e7ec5521b78bb2df48f4e0.zip",
)

load("@rules_android_ndk//:rules.bzl", "android_ndk_repository")

load("//third_party:android_configure.bzl", "android_configure")

android_configure(name = "local_config_android")

load("@local_config_android//:android_configure.bzl", "android_workspace")

android_workspace()
android_workspace(android_ndk_repository)

http_archive(
name = "build_bazel_rules_apple",
Expand Down Expand Up @@ -516,7 +525,7 @@ http_archive(
build_file = "@mediapipe//third_party:opencv_android.BUILD",
strip_prefix = "OpenCV-android-sdk",
type = "zip",
url = "https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-android-sdk.zip",
url = "https://github.com/opencv/opencv/releases/download/4.12.0/opencv-4.12.0-android-sdk.zip",
)

# After OpenCV 3.2.0, the pre-compiled opencv2.framework has google protobuf symbols, which will
Expand Down
12 changes: 6 additions & 6 deletions docker/linux/x86_64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG UID=1000
ARG ANDROID_SDK_BUILD_TOOLS_VERSION=30.0.3
ARG ANDROID_SDK_VERSION=30
ARG ANDROID_NDK_VERSION=21.4.7075529
ARG ANDROID_SDK_BUILD_TOOLS_VERSION=35.0.0
ARG ANDROID_SDK_VERSION=36
ARG ANDROID_NDK_VERSION=28.2.13676358

FROM ubuntu:22.04 AS base

Expand All @@ -22,7 +22,7 @@ RUN apt-get update && \
mesa-common-dev \
nasm \
npm \
openjdk-11-jdk \
openjdk-17-jdk \
pkg-config \
software-properties-common \
sudo \
Expand Down Expand Up @@ -74,10 +74,10 @@ ARG ANDROID_SDK_VERSION
ARG ANDROID_NDK_VERSION

ENV COMMANDLINETOOLS_ZIP=commandlinetools.zip
ENV COMMANDLINETOOLS_SHA256=124f2d5115eee365df6cf3228ffbca6fc3911d16f8025bebd5b1c6e2fcfa7faf
ENV COMMANDLINETOOLS_SHA256=7ec965280a073311c339e571cd5de778b9975026cfcbe79f2b1cdcb1e15317ee


RUN curl -L https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip -o ${COMMANDLINETOOLS_ZIP} && \
RUN curl -L https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip -o ${COMMANDLINETOOLS_ZIP} && \
(test "$(sha256sum ${COMMANDLINETOOLS_ZIP})" = "${COMMANDLINETOOLS_SHA256} ${COMMANDLINETOOLS_ZIP}" || { echo 'Checksum Failed'; exit 1; }) && \
unzip ${COMMANDLINETOOLS_ZIP} -d /opt/android

Expand Down
20 changes: 10 additions & 10 deletions docker/windows/x86_64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

ARG NODE_VERSION=18.17.1
ARG PYTHON_VERSION=3.12.8
ARG ANDROID_SDK_VERSION=30
ARG ANDROID_NDK_VERSION=21.4.7075529
ARG ANDROID_SDK_VERSION=36
ARG ANDROID_NDK_VERSION=28.2.13676358

FROM mcr.microsoft.com/windows/servercore:ltsc2022 as base

Expand Down Expand Up @@ -80,21 +80,21 @@ FROM builder as android
ARG ANDROID_SDK_VERSION
ARG ANDROID_NDK_VERSION

ENV OPENJDK_ZIP OpenJDK11U-jdk_x64.zip
ENV OPENJDK_SHA256 087d096032efe273d7e754a25c85d8e8cf44738a3e597ad86f55e0971acc3b8e
ENV JAVA_HOME C:\Java\jdk-11.0.13+8
ENV OPENJDK_ZIP OpenJDK17U-jdk_x64.zip
ENV OPENJDK_SHA256 d1b2bb5a074ba33a0cf4e84aa558f7a563b827f999a71c8e47bdb0dd02af6b9c
ENV JAVA_HOME C:\Java\jdk-17.0.9+9

# Install Java
RUN curl -L --retry 4 --connect-timeout 10 https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.13%2B8/OpenJDK11U-jdk_x64_windows_hotspot_11.0.13_8.zip -o C:\TEMP\%OPENJDK_ZIP% && `
RUN curl -L --retry 4 --connect-timeout 10 https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9.1/OpenJDK17U-jdk_x64_windows_hotspot_17.0.9_9.zip -o C:\TEMP\%OPENJDK_ZIP% && `
for /F %s in ('sha256sum /c/TEMP/%OPENJDK_ZIP%') do ((test "%s" = "%OPENJDK_SHA256%" || (echo %s 'Checksum Failed' && exit 1))) && `
unzip C:\TEMP\%OPENJDK_ZIP% -d C:\Java && `
del C:\TEMP\%OPENJDK_ZIP%

ENV COMMANDLINETOOLS_ZIP commandlinetools.zip
ENV COMMANDLINETOOLS_SHA256 f9e6f91743bcb1cc6905648ca751bc33975b0dd11b50d691c2085d025514278c
ENV COMMANDLINETOOLS_SHA256 98b565cb657b012dae6794cefc0f66ae1efb4690c699b78a614b4a6a3505b003

# Install Android SDK and NDK
RUN curl -L --retry 4 --connect-timeout 10 https://dl.google.com/android/repository/commandlinetools-win-7583922_latest.zip -o C:\TEMP\%COMMANDLINETOOLS_ZIP% && `
RUN curl -L --retry 4 --connect-timeout 10 https://dl.google.com/android/repository/commandlinetools-win-13114758_latest.zip -o C:\TEMP\%COMMANDLINETOOLS_ZIP% && `
for /F %s in ('sha256sum /c/TEMP/%COMMANDLINETOOLS_ZIP%') do ((test "%s" = "%COMMANDLINETOOLS_SHA256%" || (echo 'Checksum Failed' && exit 1))) && `
unzip C:\TEMP\%COMMANDLINETOOLS_ZIP% -d C:\Android && `
del C:\TEMP\%COMMANDLINETOOLS_ZIP%
Expand All @@ -103,7 +103,7 @@ RUN curl -L --retry 4 --connect-timeout 10 https://dl.google.com/android/reposit
RUN powershell -command "for($i=0;$i -lt 30;$i++) { $response += """y`n""" }; $response" | C:\Android\cmdline-tools\bin\sdkmanager --sdk_root=C:\Android --licenses && `
C:\Android\cmdline-tools\bin\sdkmanager --sdk_root=C:\Android --install `
"platforms;android-%ANDROID_SDK_VERSION%" `
"build-tools;30.0.3" `
"build-tools;35.0.0" `
"ndk;%ANDROID_NDK_VERSION%"


Expand All @@ -115,7 +115,7 @@ ENV ANDROID_HOME C:\Android
ENV ANDROID_NDK_HOME ${ANDROID_HOME}\ndk\${ANDROID_NDK_VERSION}
ENV PYTHON_INSTALL_PATH=C:\Python
ENV PYTHON_BIN_PATH=${PYTHON_INSTALL_PATH}\python.exe
ENV HERMETIC_PYTHON_VERSION 3.9
ENV HERMETIC_PYTHON_VERSION 3.12

# Install Bazel and NuGet
RUN setx path "C:\bin;%PYTHON_INSTALL_PATH%;%PYTHON_INSTALL_PATH%\Scripts;%PATH%" && `
Expand Down
9 changes: 1 addition & 8 deletions docs/Build.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,6 @@ When building for Android (Linux/macOS), follow these additional steps:

1. Launch Android Studio, open **SDK Manager > SDK Tools**, and install Android SDK Build Tools and Android NDK

> :bell: Please note the following two points:
>
> - While Bazel automatically uses the latest installed Build Tools, versions 31.0.0 and above do not work properly, so you need to uncheck versions 31.0.0 and above.
> - Since NDK versions r22 and above are not supported, please use NDK version 21.4.7075529 or lower.
>
> ![Android Studio (SDK Tools)](https://user-images.githubusercontent.com/4690128/144735652-21339ab0-5a45-4277-b7ee-39d106b5e1e6.png)

1. Set environment variables

```sh
Expand All @@ -307,7 +300,7 @@ When building for Android (Linux/macOS), follow these additional steps:
export ANDROID_HOME=/path/to/SDK

# Set ANDROID_NDK_HOME
# This is typically something like `$ANDROID_HOME/ndk/21.4.7075529`
# This is typically something like `$ANDROID_HOME/ndk/28.2.13676358`
export ANDROID_NDK_HOME=/path/to/NDK
```

Expand Down
6 changes: 6 additions & 0 deletions mediapipe_api/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ cc_library(
"//mediapipe_api/gpu:gpu_shared_data_internal",
],
}),
linkopts = select({
"@mediapipe//mediapipe:android": [
"-Wl,-z,max-page-size=16384",
],
"//conditions:default": [],
}),
alwayslink = True,
)

Expand Down
2 changes: 1 addition & 1 deletion mediapipe_api/java/com/google/mediapipe/mediapipe_aar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Macro to generate AAR, including libmediapipe_jni.so

load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")

def mediapipe_aar(name, package = "com.github.homuler.mediapipe", srcs = [], deps = [], jni_deps = [], assets = [], assets_dir = "", target_sdk_version = 34, min_sdk_version = 21):
def mediapipe_aar(name, package = "com.github.homuler.mediapipe", srcs = [], deps = [], jni_deps = [], assets = [], assets_dir = "", target_sdk_version = 35, min_sdk_version = 21):
"""Generate MediaPipeUnityPlugin AAR.

Args:
Expand Down
8 changes: 5 additions & 3 deletions third_party/android_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ def _android_autoconf_impl(repository_ctx):
ndk_rule = ""
if ndk_home:
if not ndk_api_level:
ndk_rule = """native.android_ndk_repository(name="androidndk")"""
ndk_rule = """android_ndk_repository(name="androidndk")"""
else:
ndk_rule = """
native.android_ndk_repository(
android_ndk_repository(
name="androidndk",
api_level={},
)
Expand All @@ -68,9 +68,11 @@ def _android_autoconf_impl(repository_ctx):

repository_ctx.file("BUILD.bazel", "")
repository_ctx.file("android_configure.bzl", """
def android_workspace():
def android_workspace(android_ndk_repository):
{}
{}
# See https://github.com/bazelbuild/rules_android_ndk/issues/31#issuecomment-1396182185
native.bind(name = "android/crosstool", actual = "@androidndk//:toolchain")
""".format(sdk_rule, ndk_rule))

android_configure = repository_rule(
Expand Down