APK批量签名脚本 2016-05-12- 2022-07-24v1签名12345678910111213141516171819202122232425262728293031323334353637383940#! /bin/shfunction signApk{ echo "=========Start sign apk ### $1 ### with keystore. " jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore keystore文件路径 -storepass 密码 $1 签名证书别名 echo "=========Start zipalign apk ." zipalign -f -v 4 $1 ./release/$2_realease.apk}# get this script path# filepath=$(cd "$(dirname "$0")"; pwd)# go into the script foldercd `dirname $0`# check command jarsigner exsitcommand -v jarsigner >/dev/null 2>&1 || { echo >&2 "I require jarsigner but it's not found. Aborting."; exit 1; }# make a folder to storage apk after sign and zipalignmkdir ./releasefor entry in ./*do echo "$entry" file=$entry# echo “filename: ${file%.*}” extension=${file##*.} echo "$extension"if [ "$extension" = "apk" ]; then echo "is a APK" fileName=${file%.*} isRelease=${fileName#./FILE_NAME*_} if [ "$isRelease" = "release" ]; then echo "is a release version ,so ignore" else echo "not a release version,start sign..." signApk $file $fileName; fielse echo "not a apk file, ignore"fidone echo "sign all apk file successfully!" v2签名123456789101112131415161718192021222324252627282930313233343536373839404142#! /bin/shfunction signApk{ echo "=========Start sign apk ### $1 ### with keystore. " jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore -keystore keystore文件路径 -storepass 密码 $1 签名证书别名 echo "=========Start zipalign apk ." zipalign -f -v 4 $1 ./release/$2_realease.apk echo "=========Start v2 sign apk ### $2_realease.apk ### with keystore. " apksigner sign -v --ks keystore文件路径 --ks-key-alias 签名证书别名 --ks-pass pass:密码 --key-pass pass:密码 --out ./release_v2/$2_realease_v2.apk ./release/$2_realease.apk }# get this script path# filepath=$(cd "$(dirname "$0")"; pwd)# go into the script foldercd `dirname $0`# check command jarsigner exsitcommand -v jarsigner >/dev/null 2>&1 || { echo >&2 "I require jarsigner but it's not found. Aborting."; exit 1; }# make a folder to storage apk after sign and zipalignmkdir ./releasemkdir ./release_v2for entry in ./*do echo "$entry" file=$entry# echo “filename: ${file%.*}” extension=${file##*.} echo "$extension"if [ "$extension" = "apk" ]; then echo "is a APK" fileName=${file%.*} isRelease=${fileName#./FILE_NAME*_} if [ "$isRelease" = "release" ]; then echo "is a release version ,so ignore" else echo "not a release version,start sign..." signApk $file $fileName; fielse echo "not a apk file, ignore"fidone echo "sign all apk file successfully!"我很可爱,请给我钱本文作者:Cat本文链接:https://szxiot.com/2016/05/12/apk-sign-script/版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。