Skip to content

Commit 52138fd

Browse files
committed
Update script to build without gradle to SDK 31
Build tools 31.x.x do not ship dx anymore. Use d8 instead. Refs 8bf28e9
1 parent 1bb0df5 commit 52138fd

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

server/build_without_gradle.sh

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ set -e
1414
SCRCPY_DEBUG=false
1515
SCRCPY_VERSION_NAME=1.19
1616

17-
PLATFORM=${ANDROID_PLATFORM:-30}
18-
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-30.0.0}
17+
PLATFORM_VERSION=31
18+
PLATFORM=${ANDROID_PLATFORM:-$PLATFORM_VERSION}
19+
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-31.0.0}
1920

2021
BUILD_DIR="$(realpath ${BUILD_DIR:-build_manual})"
2122
CLASSES_DIR="$BUILD_DIR/classes"
@@ -55,16 +56,33 @@ javac -bootclasspath "$ANDROID_JAR" -cp "$CLASSES_DIR" -d "$CLASSES_DIR" \
5556

5657
echo "Dexing..."
5758
cd "$CLASSES_DIR"
58-
"$ANDROID_HOME/build-tools/$BUILD_TOOLS/dx" --dex \
59-
--output "$BUILD_DIR/classes.dex" \
60-
android/view/*.class \
61-
android/content/*.class \
62-
com/genymobile/scrcpy/*.class \
63-
com/genymobile/scrcpy/wrappers/*.class
6459

65-
echo "Archiving..."
66-
cd "$BUILD_DIR"
67-
jar cvf "$SERVER_BINARY" classes.dex
68-
rm -rf classes.dex classes
60+
if [[ $PLATFORM_VERSION -lt 31 ]]
61+
then
62+
# use dx
63+
"$ANDROID_HOME/build-tools/$BUILD_TOOLS/dx" --dex \
64+
--output "$BUILD_DIR/classes.dex" \
65+
android/view/*.class \
66+
android/content/*.class \
67+
com/genymobile/scrcpy/*.class \
68+
com/genymobile/scrcpy/wrappers/*.class
69+
70+
echo "Archiving..."
71+
cd "$BUILD_DIR"
72+
jar cvf "$SERVER_BINARY" classes.dex
73+
rm -rf classes.dex classes
74+
else
75+
# use d8
76+
"$ANDROID_HOME/build-tools/$BUILD_TOOLS/d8" --classpath "$ANDROID_JAR" \
77+
--output "$BUILD_DIR/classes.zip" \
78+
android/view/*.class \
79+
android/content/*.class \
80+
com/genymobile/scrcpy/*.class \
81+
com/genymobile/scrcpy/wrappers/*.class
82+
83+
cd "$BUILD_DIR"
84+
mv classes.zip "$SERVER_BINARY"
85+
rm -rf classes
86+
fi
6987

7088
echo "Server generated in $BUILD_DIR/$SERVER_BINARY"

0 commit comments

Comments
 (0)