Created
August 9, 2017 17:15
-
-
Save amitpdev/f03a0a591dbfbcc6ea429b54c4e01f95 to your computer and use it in GitHub Desktop.
Generate a signed APK for Android with React Native
This file contains 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
#!/bin/bash | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 <certificate_key.jks>" | |
exit 1 | |
fi | |
function loginfo { | |
GREEN="\033[92m" | |
CLEAR="\033[0m" | |
echo -e "${GREEN}[INFO] ${1}${CLEAR}" | |
} | |
loginfo "Bundling React Native resources" | |
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/ | |
loginfo "Deleting old apk files" | |
cd android | |
\rm *.apk 2>/dev/null | |
\rm app/build/outputs/apk/*.apk 2>/dev/null | |
loginfo "Compiling release build" | |
./gradlew assembleRelease | |
cd .. | |
loginfo "Aligning archive" | |
zipalign -v -p 4 android/app/build/outputs/apk/app-release-unsigned.apk android/app-unsigned-aligned.apk | |
loginfo "Signing archive" | |
apksigner sign --ks $1 --out nester-release.apk --ks-pass stdin --key-pass stdin android/app-unsigned-aligned.apk | |
loginfo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment