Skip to content

Commit

Permalink
feat: use apksigner for v2 v3 signing
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinasokan committed Aug 9, 2022
1 parent b71c3bf commit 8a5608a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func alignAPK() {
func signAPK(keyStore, storePass, keyAlias *string) {
LogI("build", "signing app")

cmd := exec.Command(jarsignerPath, "-verbose", "-sigalg", "SHA1withRSA", "-digestalg", "SHA1", "-storepass", *storePass, "-keystore", *keyStore, filepath.Join("build", "bundle.zip"), *keyAlias)
cmd := exec.Command(apksignerPath, "sign", "--ks-pass", "pass:"+*storePass, "--ks", *keyStore, "--ks-key-alias", *keyAlias, filepath.Join("build", "app.apk"))
out, err := cmd.CombinedOutput()
if err != nil {
LogF("build", string(out))
Expand Down
2 changes: 1 addition & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func build() {
if *useAAB {
buildAAB()
} else {
signAPK(keyStore, storePass, keyAlias)
alignAPK()
signAPK(keyStore, storePass, keyAlias)
}
}

Expand Down
25 changes: 12 additions & 13 deletions doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import (

var (
// java sdk paths
javaPath string
javaBinPath string
javacPath string
jarsignerPath string
javaPath string
javaBinPath string
javacPath string

// android sdk paths
sdkPath string
toolsPath string
zipAlignPath string
aapt2Path string
d8Path string
adbPath string
sdkPath string
toolsPath string
zipAlignPath string
aapt2Path string
d8Path string
apksignerPath string
adbPath string

// android java apis
androidJar string
Expand All @@ -40,12 +40,12 @@ func doctor() {

LogI("doctor", "java", javaPath)
LogI("doctor", "javac", javacPath)
LogI("doctor", "jarsigner", jarsignerPath)

LogI("doctor", "sdk", sdkPath)
LogI("doctor", "aapt2", aapt2Path)
LogI("doctor", "d8", d8Path)
LogI("doctor", "zipalign", zipAlignPath)
LogI("doctor", "apksigner", apksignerPath)

LogI("doctor", "android jar", androidJar)
}
Expand Down Expand Up @@ -84,6 +84,7 @@ func findSDKs() {
aapt2Path = filepath.Join(toolsPath, "aapt2")
d8Path = filepath.Join(toolsPath, "d8")
zipAlignPath = filepath.Join(toolsPath, "zipalign")
apksignerPath = filepath.Join(toolsPath, "apksigner")
adbPath = filepath.Join(sdkPath, "platform-tools", "adb")
api := strings.Split(btVersion, ".")[0]
androidJar = filepath.Join(sdkPath, "platforms", "android-"+api, "android.jar")
Expand All @@ -93,12 +94,10 @@ func findSDKs() {
if javaPath != "" {
javaBinPath = filepath.Join(javaPath, "bin")
javacPath = filepath.Join(javaBinPath, "javac")
jarsignerPath = filepath.Join(javaBinPath, "jarsigner")
} else {
LogW("doctor", "JAVA_HOME was not found in environment")
// hope the bin is in path
javacPath = "javac"
jarsignerPath = "jarsigner"
}
}

Expand Down

0 comments on commit 8a5608a

Please sign in to comment.