Created
May 12, 2020 07:41
-
-
Save kyle-seongwoo-jun/d31e67d7d790879367f30ab88068451e to your computer and use it in GitHub Desktop.
Convert aab(Android App Bundle) file to apk file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($PACKAGE_NAME) | |
$KEY_STORE = "" | |
$KEY_STORE_PASSWORD = "" | |
$KEY_ALIAS = "" | |
$KEY_PASSWORD = "" | |
# get latest bundle tool info | |
$GITHUB_REQUEST = Invoke-RestMethod "https://api.github.com/repos/google/bundletool/releases/latest" | |
$GITHUB_ASSET = $GITHUB_REQUEST.assets[0] | |
# check exists bundle tool | |
$BUNDLE_TOOL_NAME = $GITHUB_ASSET.name | |
if (-Not (Test-Path $BUNDLE_TOOL_NAME)) | |
{ | |
# download bundle tool | |
$BUNDLE_TOOL_DOWNLOAD_URL = $GITHUB_ASSET.browser_download_url | |
echo "Downloading latest bundle tool: $BUNDLE_TOOL_NAME" | |
Invoke-WebRequest $BUNDLE_TOOL_DOWNLOAD_URL -OutFile $BUNDLE_TOOL_NAME | |
} | |
# generate apk file | |
echo "Generating APK file..." | |
java -jar $BUNDLE_TOOL_NAME build-apks --mode=universal ` | |
--bundle="$PACKAGE_NAME.aab" --output="$PACKAGE_NAME.apks" ` | |
--ks=$KEY_STORE ` | |
--ks-pass=pass:$KEY_STORE_PASSWORD ` | |
--ks-key-alias=$KEY_ALIAS ` | |
--key-pass=pass:$KEY_PASSWORD | |
# unzip apks file | |
Expand-Archive "$PACKAGE_NAME.apks" -DestinationPath . | |
# get result file | |
rm "$PACKAGE_NAME.apks" | |
rm toc.pb | |
mv universal.apk "$PACKAGE_NAME.apk" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ aab2apk com.companyname.appname | |
Downloading latest bundle tool: bundletool-all-0.14.0.jar | |
Generating APK file... | |
$ Test-Path .\com.companyname.appname.apk | |
True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment