From 52138fd9213216a21fbdcda4d430394d7c8f0979 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 14 Nov 2021 00:23:36 +0100 Subject: [PATCH] Update script to build without gradle to SDK 31 Build tools 31.x.x do not ship dx anymore. Use d8 instead. Refs 8bf28e9f5340d2a54dbc9b2c9d924b7ee4fa8d31 --- server/build_without_gradle.sh | 42 ++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/server/build_without_gradle.sh b/server/build_without_gradle.sh index 926c19f5..c33ee47a 100755 --- a/server/build_without_gradle.sh +++ b/server/build_without_gradle.sh @@ -14,8 +14,9 @@ set -e SCRCPY_DEBUG=false SCRCPY_VERSION_NAME=1.19 -PLATFORM=${ANDROID_PLATFORM:-30} -BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-30.0.0} +PLATFORM_VERSION=31 +PLATFORM=${ANDROID_PLATFORM:-$PLATFORM_VERSION} +BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-31.0.0} BUILD_DIR="$(realpath ${BUILD_DIR:-build_manual})" CLASSES_DIR="$BUILD_DIR/classes" @@ -55,16 +56,33 @@ javac -bootclasspath "$ANDROID_JAR" -cp "$CLASSES_DIR" -d "$CLASSES_DIR" \ echo "Dexing..." cd "$CLASSES_DIR" -"$ANDROID_HOME/build-tools/$BUILD_TOOLS/dx" --dex \ - --output "$BUILD_DIR/classes.dex" \ - android/view/*.class \ - android/content/*.class \ - com/genymobile/scrcpy/*.class \ - com/genymobile/scrcpy/wrappers/*.class -echo "Archiving..." -cd "$BUILD_DIR" -jar cvf "$SERVER_BINARY" classes.dex -rm -rf classes.dex classes +if [[ $PLATFORM_VERSION -lt 31 ]] +then + # use dx + "$ANDROID_HOME/build-tools/$BUILD_TOOLS/dx" --dex \ + --output "$BUILD_DIR/classes.dex" \ + android/view/*.class \ + android/content/*.class \ + com/genymobile/scrcpy/*.class \ + com/genymobile/scrcpy/wrappers/*.class + + echo "Archiving..." + cd "$BUILD_DIR" + jar cvf "$SERVER_BINARY" classes.dex + rm -rf classes.dex classes +else + # use d8 + "$ANDROID_HOME/build-tools/$BUILD_TOOLS/d8" --classpath "$ANDROID_JAR" \ + --output "$BUILD_DIR/classes.zip" \ + android/view/*.class \ + android/content/*.class \ + com/genymobile/scrcpy/*.class \ + com/genymobile/scrcpy/wrappers/*.class + + cd "$BUILD_DIR" + mv classes.zip "$SERVER_BINARY" + rm -rf classes +fi echo "Server generated in $BUILD_DIR/$SERVER_BINARY"