diff --git a/README.md b/README.md index b7604a9..939acb8 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ $ apkc run .... ``` +To build APK with custom key store run `apkc build --keystore "/path/to/keystore.jks" --storepass "password" --keyalias "alias"`. + To build AAB run `apkc build --aab`. Output file will be at `build/app.{apk/aab}`. You can add external jar dependencies to `myapp/jar` directory and native libs to `myapp/lib` in appropriate architecture sub directories. diff --git a/apk.go b/apk.go index 356966a..66426e1 100644 --- a/apk.go +++ b/apk.go @@ -17,10 +17,10 @@ func alignAPK() { } // signAPK signs apk with jarsigner and default debug keys -func signAPK() { +func signAPK(keyStore, storePass, keyAlias *string) { LogI("build", "signing app") - cmd := exec.Command(jarsignerPath, "-verbose", "-sigalg", "SHA1withRSA", "-digestalg", "SHA1", "-storepass", "android", "-keystore", keyStorePath, filepath.Join("build", "bundle.zip"), "androiddebugkey") + cmd := exec.Command(jarsignerPath, "-verbose", "-sigalg", "SHA1withRSA", "-digestalg", "SHA1", "-storepass", *storePass, "-keystore", *keyStore, filepath.Join("build", "bundle.zip"), *keyAlias) out, err := cmd.CombinedOutput() if err != nil { LogF("build", string(out)) diff --git a/build.go b/build.go index 321176e..4e42be4 100644 --- a/build.go +++ b/build.go @@ -13,7 +13,12 @@ import ( // build compiles all the source code and bundles into apk file with dependencies func build() { buildCmd := flag.NewFlagSet("build", flag.ExitOnError) + useAAB := buildCmd.Bool("aab", false, "build aab instead of apk") + keyStore := buildCmd.String("keystore", keyStorePath, "path to keystore") + storePass := buildCmd.String("storepass", "android", "keystore password") + keyAlias := buildCmd.String("keyalias", "androiddebugkey", "key alias to use") + buildCmd.Parse(os.Args[2:]) prepare() @@ -25,7 +30,7 @@ func build() { if *useAAB { buildAAB() } else { - signAPK() + signAPK(keyStore, storePass, keyAlias) alignAPK() } }