From c21581aefa72d6ed88c994a5c147512816e9bd2c Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 25 Feb 2024 18:29:10 -0500 Subject: [PATCH] Use zipalign w/zopfli for APKs to save a little on size. --- GNUmakefile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 06999e59..3fdf50ac 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -722,10 +722,11 @@ out/apk/TildeFriends-arm-%.unsigned.apk: @cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/tildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/tildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/tildefriends.so - @cp out/apk/res.apk $@ + @cp out/apk/res.apk $@.zip @cp out/apk/classes.dex out/apk-arm-$(BUILD_TYPE)/ - @cd out/apk-arm-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../ - @zip -u $@ -q -9 $(RAW_FILES) + @cd out/apk-arm-$(BUILD_TYPE) && zip -u ../../$@.zip -q -9 -r . && cd ../../ + @zip -u $@.zip -q $(RAW_FILES) + @rm -f $@ && $(ANDROID_BUILD_TOOLS)/zipalign -z 4 $@.zip $@ out/apk/TildeFriends-x86-%.unsigned.apk: @mkdir -p $(dir $@) out/apk-x86-$(BUILD_TYPE)/lib/x86_64/ out/apk-x86-$(BUILD_TYPE)/lib/x86/ @@ -734,14 +735,15 @@ out/apk/TildeFriends-x86-%.unsigned.apk: @cp out/android$(BUILD_TYPE)-x86/tildefriends out/apk-x86-$(BUILD_TYPE)/lib/x86/tildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86_64/tildefriends.so @$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86/tildefriends.so - @cp out/apk/res.apk $@ + @cp out/apk/res.apk $@.zip @cp out/apk/classes.dex out/apk-x86-$(BUILD_TYPE)/ - @cd out/apk-x86-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../ - @zip -u $@ -q -9 $(RAW_FILES) + @cd out/apk-x86-$(BUILD_TYPE) && zip -u ../../$@.zip -q -9 -r . && cd ../../ + @zip -u $@.zip -q $(RAW_FILES) + @rm -f $@ && $(ANDROID_BUILD_TOOLS)/zipalign -z 4 $@.zip $@ out/%.apk: out/apk/%.unsigned.apk @echo "[apksigner] $(notdir $@)" - @$(ANDROID_BUILD_TOOLS)/apksigner sign --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --out $@ $< + @$(ANDROID_BUILD_TOOLS)/apksigner sign --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --min-sdk-version $(ANDROID_MIN_SDK_VERSION) --out $@ $< release-apk: out/TildeFriends-arm-release.apk out/TildeFriends-x86-release.apk .PHONY: release-apk