You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
868 B

#!/bin/sh
dir="$(mktemp -d)"
echo "=> $dir"
if test ! -f my-release-key.keystore; then
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
fi
# force-all because $dir already exists
apktool decode "$1" --force-all --output "$dir" || exit 1
# https://stackoverflow.com/questions/50461881/java-lang-noclassdeffounderrorfailed-resolution-of-lorg-apache-http-protocolve#50779232
sed -i "s/<\/application>/<uses-library android:name=\"org.apache.http.legacy\" android:required=\"false\" \/><\/application>/" "$dir/AndroidManifest.xml" || exit 1
apktool build "$dir" || exit 1
mv "$dir"/dist/* "$dir/dist/output.apk"
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore "$dir/dist/output.apk" alias_name || exit 1
cp "$dir/dist/output.apk" . || exit 1
rm -rf "$dir"