Skip to content

Instantly share code, notes, and snippets.

@junjanjon
Created November 8, 2022 08:38
Show Gist options
  • Save junjanjon/6fb0987cbe6d1add44eaf131e5e69a83 to your computer and use it in GitHub Desktop.
Save junjanjon/6fb0987cbe6d1add44eaf131e5e69a83 to your computer and use it in GitHub Desktop.
未署名 apk を署名 apk にする
#!/bin/bash -xeu
# jarsigner で署名する
# zipalign でアライメントする
# 使用方法: jarsigner [options] jar-file alias
# [-verbose[:suboptions]] 署名/検証時の詳細出力。
# サブオプションとして、all、groupedまたはsummaryを使用できます
# [-sigalg <algorithm>] シグネチャ・アルゴリズムの名前
# [-digestalg <algorithm>] ダイジェスト・アルゴリズムの名前
# [-keystore <url>] キーストアの位置
# [-storepass <password>] キーストア整合性のためのパスワード
# [-keypass <password>] 秘密鍵のパスワード(異なる場合)
# [-signedjar <file>] 署名付きJARファイルの名前
jarsigner \
-verbose \
-sigalg SHA1withRSA \
-digestalg SHA1 \
-keystore ./develop.keystore \
-storepass ${KEY_STORE_PASS} \
-signedjar signed.apk \
unsigned.apk \
${KEY_NAME}
# Zip alignment utility
# https://developer.android.com/studio/command-line/zipalign?hl=ja
# Copyright (C) 2009 The Android Open Source Project
# Usage: zipalign [-f] [-p] [-v] [-z] <align> infile.zip outfile.zip
# zipalign -c [-p] [-v] <align> infile.zip
# <align>: alignment in bytes, e.g. '4' provides 32-bit alignment
# -c: check alignment only (does not modify file)
# -f: overwrite existing outfile.zip
# -p: memory page alignment for stored shared object files
# -v: verbose output
# -z: recompress using Zopfli
~/local-android/sdk-root/build-tools/30.0.3/zipalign \
-f -p -v 4 signed.apk develop.apk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment