Skip to content

Instantly share code, notes, and snippets.

@sgobotta
Last active September 6, 2019 15:36
Show Gist options
  • Save sgobotta/bcab62fdf8a36f99f722733221695aed to your computer and use it in GitHub Desktop.
Save sgobotta/bcab62fdf8a36f99f722733221695aed to your computer and use it in GitHub Desktop.

Build scripts

Sources:

Produce Android App (.apk)

tns build android \
  --bundle --release \
  --key-store-path your/path/to/the/keystore \
  --key-store-password your-keystore-password \
  --key-store-alias your-keystore-alias \
  --key-store-alias-password your-keystore-alias-password \
  --compileSdk 28

Produce Android App Bundle (.aab)

tns build android \
  --release \
  --compileSdk 28 \
  --key-store-path your-keystore-path \
  --key-store-password your-keystore-password \
  --key-store-alias your-keystore-alias \
  --key-store-alias-password your-keystore-alias-password \
  --aab \
  --copy-to an/output/directory/aabs/app-release.aab

Testing the produced .aab file

export BUNDLETOOL_PATH=/path/to/your/android-bundletool/android/bundletool/0.10.2/bundletool.jar
export BUNDLETOOL_INPUT=/an/output/directory/aabs/app-release.aab
export BUNDLETOOL_OUTPUT=/an/output/directory/app-release.apks
export KEYSTORE_FILE=/your/path/to/the/keystore
export KEYSTORE_PASS=your-keystore-password
export KEYSTORE_ALIAS=your-keystore-alias
java \
  -jar $BUNDLETOOL_PATH build-apks \
  --bundle=$BUNDLETOOL_INPUT  \
  --output=$BUNDLETOOL_OUTPUT \
  --ks=$KEYSTORE_FILE \
  --ks-pass=pass:$KEYSTORE_PASS \
  --ks-key-alias=$KEYSTORE_ALIAS \
  --key-pass=pass:$KEYSTORE_PASS

Get your device id with adb

export DEVICE_ID=`adb devices | tail +2 | cut -f1`

Install the application on a connected device

java \
  -jar $BUNDLETOOL_PATH install-apks \
  --apks="$BUNDLETOOL_OUTPUT" \
  --device-id=$DEVICE_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment