flutter build commands

반응형

 

https://blog.codemagic.io/environments-in-flutter-with-codemagic-cicd/

https://github.com/codemagic-ci-cd/codemagic-sample-projects/tree/main/flutter/flutter-flavors-demo-project

https://medium.com/@animeshjain/build-flavors-in-flutter-android-and-ios-with-different-firebase-projects-per-flavor-27c5c5dac10b

 

 

https://docs.flutter.dev/perf/app-size#reducing-app-size




* Run Debug

 

By default, flutter run compiles to debug mode.

 

Dev : flutter run -t lib/main_dev.dart --flavor dev

Stag : flutter run -t lib/main_stag.dart --flavor stag

Prod : flutter run -t lib/main_prod.dart --flavor prod





* Android Build

 

By default flutter build build for release mode. So you can just do flutter build

By default there isn’t any target-platform then all of android-arm,android-arm64,android-x64

 

Using --split-debug-info flag can dramatically reduce code size. For an example of using this flag, see Obfuscating Dart code.

 

flutter build --release

flutter build apk --release

flutter build appbundle --release

 

flutter build apk -t lib/main_dev.dart --flavor dev --target-platform android-arm,android-arm64,android-x64

flutter build apk -t lib/main_stag.dart --flavor stag --target-platform android-arm,android-arm64,android-x64

flutter build apk -t lib/main_prod.dart --flavor dev --target-platform android-arm,android-arm64,android-x64



APK? APK file (Android Application Package)

These commands will make each apks file for each target platform.

flutter build app bundle builds for 3 platforms: ARM 32-bit, ARM 64-bit, x86 64-bit.

flutter clean

flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi



App Bundle? AAB file (Android App Bundle)

But we don’t need to make each apk file. We can use aab for real deployment.

https://developer.android.com/guide/app-bundle

https://liapp.lockincomp.com/blog/blog-Post/tech-google-android-app-bundle/

flutter build appbundle --target-platform android-arm,android-arm64,android-x64



--target-platform android-arm,android-arm64,android-x64




* iOS build

flutter build ios -t lib/main_dev.dart --flavor dev

flutter build ios -t lib/main_stag.dart --flavor stag

flutter build ios -t lib/main_prod.dart --flavor prod





Flutter package cache clear

https://stackoverflow.com/questions/55399209/update-flutter-dependencies-in-pub-cache



-t option is for the setting of the entry point of the app.

-t lib/main_dev.dart / -t lib/main_stag.dart / -t lib/main_prod.dart

Options are for the environment values of flutter app.

main_dev.dart will load the .env.dev file.

main_stag.dart will load the .env.stag file.

main_prod.dart will load the .env.prod file.

 

Each deployment is for each dev, stag, prod. So we may just use each option for each CI/CD.

And it will be the same with –flavor option.

–flavor option and -t main_xxx.dart option are different and independent but logically we should use the same option.

 

 

Run with a debug apk binary

flutter run --use-application-binary /Users/mac/Documents/dev/someapp/build/app/outputs/flutter-apk/debug.apk
 

 

반응형

댓글

Designed by JB FACTORY