File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,39 @@ jobs:
130130 exit 1
131131 fi
132132
133+ - name : Install UPX
134+ run : |
135+ wget -q https://github.com/upx/upx/releases/download/v4.2.1/upx-4.2.1-amd64_linux.tar.xz
136+ tar -xf upx-4.2.1-amd64_linux.tar.xz
137+ sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin/
138+ upx --version
139+
140+ - name : Compress APK with UPX
141+ run : |
142+ cd .build
143+ for apk in *.apk; do
144+ echo "压缩前大小: $(du -h "$apk")"
145+ # 解压 APK
146+ unzip -q "$apk" -d "${apk%.apk}_extracted"
147+
148+ # 对 lib 目录下的 .so 文件使用 UPX 压缩
149+ find "${apk%.apk}_extracted/lib" -name "*.so" -type f | while read so_file; do
150+ echo "正在压缩: $so_file"
151+ upx --best --lzma "$so_file" || echo "警告: $so_file 压缩失败,继续处理"
152+ done
153+
154+ # 重新打包 APK
155+ cd "${apk%.apk}_extracted"
156+ zip -r -q "../${apk%.apk}_compressed.apk" .
157+ cd ..
158+
159+ # 替换原 APK
160+ mv "${apk%.apk}_compressed.apk" "$apk"
161+ rm -rf "${apk%.apk}_extracted"
162+
163+ echo "压缩后大小: $(du -h "$apk")"
164+ done
165+
133166 - name : List build artifacts
134167 run : |
135168 ls -lh .build/
You can’t perform that action at this time.
0 commit comments