sh 从您的Ionic项目创建签名和zipaligned APK

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 从您的Ionic项目创建签名和zipaligned APK相关的知识,希望对你有一定的参考价值。

#!/bin/bash    
# 
# Creates a signed and zipaligned APK from your Ionic project
#
# Place your keystore in the root of your project and name it <company>.keystore
# Use this script as following :
# $ ./release.sh [company] [version]
#
# Don't forget to gitignore your key and your compiled apks.
# 
# Original at https://gist.github.com/th3m4ri0/acc2003adc7dffdbbad6
# Author : Erwan d'Orgeville<info@erwandorgeville.com>

# Abort if any command returns something else than 0
set -e

company="$1"
version="$2"
appname_dirty=${PWD##*/}
appname=${appname_dirty//[^a-zA-Z]} # Keeps only a-z letters

if [[ -z "$1" ]]; then
    echo "No company name provided, aborting..."
    exit 1
fi
if [[ -z "$2" ]]; then
    echo "No version provided, aborting..."
    exit 1
fi

echo "---> Starting build v$version"

ionic build --release android

echo ""
echo ""
echo "---> Input the password for the key"
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore $company.keystore platforms/android/build/outputs/apk/android-release-unsigned.apk $company
cp platforms/android/build/outputs/apk/android-release-unsigned.apk platforms/android/build/outputs/apk/com.$company.$appname.v$version-unaligned.apk

echo ""
echo ""
echo "---> Zipaligning"

mkdir -p releases/

zipalign -v 4 platforms/android/build/outputs/apk/com.$company.$appname.v$version-unaligned.apk releases/com.$company.$appname.v$version.apk

echo ""
echo ""
echo "---> App released ! Look for com.$company.$appname.v$version.apk"

open releases/

以上是关于sh 从您的Ionic项目创建签名和zipaligned APK的主要内容,如果未能解决你的问题,请参考以下文章

Ionic Android 签名打包配置

ionic android 版本release 和 签名

如何直接从您的 Angular 项目中调用 Firebase Cloud Function

ionic 项目签名

ionic生成签名的APK方法总结

ionic3 项目常用