22 lines
868 B
Bash
Executable file
22 lines
868 B
Bash
Executable file
#!/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"
|