diff --git a/scripts/sign_apk.sh b/scripts/sign_apk.sh index d48eebfa..d8128e0b 100755 --- a/scripts/sign_apk.sh +++ b/scripts/sign_apk.sh @@ -21,13 +21,19 @@ if [ -z $JKS_KEYPASS ]; then exit 1 fi +# Zipalign +zipalign=$(find $ANDROID_HOME/build-tools -name "zipalign" -print | head -n 1) +$zipalign -v 4 $input $input.new +mv $input.new $input + # Sign -jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \ - -storepass $JKS_STOREPASS -keypass $JKS_KEYPASS \ - -keystore android.jks $input activitywatch -jarsigner -verify $input -mv $input $output +# Using apksigner instead of jarsigner since API 30+: https://stackoverflow.com/a/69473649 +apksigner sign --ks android.jks --ks-key-alias activitywatch \ + --ks-pass env:JKS_STOREPASS --key-pass env:JKS_KEYPASS \ + $input -zipalign=$(find $ANDROID_HOME/build-tools -name "zipalign" -print | head -n 1) -$zipalign -v 4 $output $output.new -mv $output.new $output +# Verify +apksigner -verify $input + +# Move to output destination +mv $input $output