Skip to content

Instantly share code, notes, and snippets.

@TechIsFun
Created March 18, 2020 14:17
Show Gist options
  • Save TechIsFun/97c0701616a2ee9409e2bea67aa5b09a to your computer and use it in GitHub Desktop.
Save TechIsFun/97c0701616a2ee9409e2bea67aa5b09a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
##################
# https://github.com/microsoft/appcenter/blob/master/sample-build-scripts/flutter/android-build/appcenter-post-clone.sh
##################
cd ..
# fail if any command fails
set -e
# debug log
set -x
cd ..
git clone -b beta https://github.com/flutter/flutter.git
export PATH=`pwd`/flutter/bin:$PATH
flutter channel stable
flutter doctor
echo "Installed flutter to `pwd`/flutter"
# execute tests
flutter test
# build APK
flutter build apk --debug
# flutter build apk --release
# flutter build appbundle --target-platform android-arm,android-arm64,android-x64
# if you need build bundle (AAB) in addition to your APK, uncomment line below and last line of this script.
#flutter build appbundle
# copy the APK where AppCenter will find it
mkdir -p android/app/build/outputs/apk/; mv build/app/outputs/apk/release/app-release.apk $_
# copy the AAB where AppCenter will find it
#mkdir -p android/app/build/outputs/bundle/; mv build/app/outputs/bundle/release/app.aab $_
@jhonatan-3a
Copy link

how would i have to modify. the script if the app has diferent flavors?

@TechIsFun
Copy link
Author

how would i have to modify. the script if the app has diferent flavors?

Try to add --flavor flag to flutter build command.
https://docs.flutter.dev/deployment/flavors

@jhonatan-3a
Copy link

jhonatan-3a commented Mar 31, 2023

maybe i didnt ask properly, anyway, i found the proper way to do it, if any one else comes across this, heres how i did it
flutter build apk --release --flavor googlePlay
flutter build appbundle --release --flavor googlePlay

copy the APK where AppCenter will find it
mkdir -p android/app/build/outputs/apk/; mv build/app/outputs/flutter-apk/app-googleplay-release.apk $_

mkdir -p android/app/build/outputs/bundle/; mv build/app/outputs/bundle/googleplayRelease/app-googleplay-release.aab $_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment