From 76ef9b6bff633fa4a608315c5146d23609527385 Mon Sep 17 00:00:00 2001 From: Tom Bannink Date: Sun, 16 Jun 2024 17:16:51 +0200 Subject: [PATCH] Attempt to fix Android build --- .github/workflows/unittests.yml | 2 +- third_party/install_android.sh | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index 67f3efac..5b6c121f 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -144,7 +144,7 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: ./third_party/install_android.sh - name: Configure Bazel - run: LCE_SET_ANDROID_WORKSPACE=1 ANDROID_SDK_HOME="/tmp/lce_android" ANDROID_NDK_HOME="/tmp/lce_android/ndk/21.4.7075529" ./configure.py + run: LCE_SET_ANDROID_WORKSPACE=1 ANDROID_SDK_HOME="/tmp/lce_android" ANDROID_SDK_API_LEVEL=30 ANDROID_NDK_HOME="/tmp/lce_android/ndk/25.2.9519653" ANDROID_NDK_API_LEVEL=30 ./configure.py shell: bash - name: Build LCE AAR run: BUILDER=bazelisk ./larq_compute_engine/tflite/java/build_lce_aar.sh diff --git a/third_party/install_android.sh b/third_party/install_android.sh index 0245e09c..3ba0a37e 100755 --- a/third_party/install_android.sh +++ b/third_party/install_android.sh @@ -4,12 +4,16 @@ set -e # **NOTE**: This requires Java 8 and won't work on never versions. See: # https://stackoverflow.com/questions/46402772/failed-to-install-android-sdk-java-lang-noclassdeffounderror-javax-xml-bind-a +# Taken from tensorflow/lite/tools/tflite-android.Dockerfile + # default LCE Android Env. variables -export ANDROID_SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip" +export ANDROID_SDK_URL="https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip" export ANDROID_HOME="/tmp/lce_android" -export ANDROID_VERSION=29 -export ANDROID_BUILD_TOOLS_VERSION=30.0.2 -export ANDROID_NDK_VERSION=21.4.7075529 +export ANDROID_API_LEVEL=30 +export ANDROID_BUILD_TOOLS_VERSION=31.0.0 +export ANDROID_NDK_VERSION=25.2.9519653 +export ANDROID_NDK_API_LEVEL=30 + # download android SDK mkdir -p $ANDROID_HOME; cd $ANDROID_HOME; @@ -19,24 +23,27 @@ curl -o lce_android_sdk.zip $ANDROID_SDK_URL; echo -e "DONE.\n\n" echo -e "Unpacking Android SDK ... " -unzip lce_android_sdk.zip; +unzip lce_android_sdk.zip -d /tmp +mkdir -p ${ANDROID_HOME}/cmdline-tools +mv /tmp/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest echo -e "DONE.\n\n" rm lce_android_sdk.zip; # install android platform and build tools echo -e "Updating SDK manager ... " -yes | $ANDROID_HOME/tools/bin/sdkmanager --licenses -$ANDROID_HOME/tools/bin/sdkmanager --update +yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses +$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --update echo -e "DONE.\n\n" echo -e "Installing Android SDK Platform and Build Tools ... " -$ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \ - "platforms;android-${ANDROID_VERSION}" \ +$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \ + "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \ + "platforms;android-${ANDROID_API_LEVEL}" \ "platform-tools" echo -e "DONE.\n\n" echo -e "Installing Android NDK ... " -$ANDROID_HOME/tools/bin/sdkmanager \ +$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \ "ndk;${ANDROID_NDK_VERSION}" echo -e "DONE.\n\n"