19

By default Android Studio use debug mode when building Flutter application. You can build the release version with the command line, see How to optimize the Flutter App size?

    flutter build apk --release

Now: how to configure Android Studio to do the same, when I run the application (Shift+F10)? I can't find this setting...

Serge Breusov
  • 1,316
  • 4
  • 11
  • 24

5 Answers5

38

You have to edit the run configuration:

Open the run configuration:

Open the run configuration

Add the --release flag:

Add the --release flag

Note that using the --release flag is not supported when you build with the Android Emulator.

boformer
  • 28,207
  • 10
  • 81
  • 66
  • Just an addition to above answer's last line as it took me 2 days to figure that out. So just to save your pain, release builds are only supported on specific architectures(armeabi-v7a arm64-v8a and x86-64), by default android emulators are created with x86 architecture image. See this https://github.com/flutter/flutter/issues/9253. – Adarsh Srivastava Jan 04 '22 at 08:21
19

In Android Studio , click on :

> Run
> Flutter Run 'main.dart' in Release Mode

enter image description here

Kab Agouda
  • 6,309
  • 38
  • 32
0
flutter build appbundle  --release --build-name=1.1.1 --build-number=3

Or you can run that in your Terminal, Remember to change build name and build number to corresponding values of your release app versioning.

James Christian Kaguo
  • 1,251
  • 15
  • 14
0

as the green play button in toolbar runs the debug mode, i switched it to release mode via:

Andi
  • 1
  • 1
-1

The best way to make your apk for release mode is that open the project -> click on the android folder then make your apk as same as generated application build in android using your .jks key and alias password and name. this is the correct way for making apk in flutter.