65

I am trying to build my release app in Flutter and when I run:

flutter run

everything works fine in debugging and test mode. But when I was trying to build a release app with:

flutter build apk

it creates an old first-release app of mine. That I created before and I try to reset the computer reset android and everything but not work what can I do to reset it and clear the cache? I'm trying almost to delete and reset everything but they don't work. What command that I have to run to fix it and create new version release apk

MendelG
  • 14,885
  • 4
  • 25
  • 52
javad bat
  • 4,236
  • 6
  • 26
  • 44

8 Answers8

123

The solution is easy.
Just run flutter clean and run flutter build apk after that and it generates the updated app apk.
If you want to install it directly just run flutter install after the build command.

maxmitz
  • 258
  • 1
  • 4
  • 17
javad bat
  • 4,236
  • 6
  • 26
  • 44
14

run these command

flutter clean

and after that

flutter build apk --release
Arun Aditya
  • 828
  • 8
  • 10
6

To all the beginners If you wish to release an apk of a flutter app just do: flutter run --release (and make sure to connect your device to a phone) steps to ensure your phone is connected: 1. enable usb debugging mode in your phone 2.click on version number of your phone in system settings to enter into developer mode 3. change the phone mode to transferring file mode

After you run the command go to build->apps->output->apk

Palak Mantry
  • 59
  • 1
  • 4
2

Run this command for making a bundle.

flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Sumit Singh
  • 1,150
  • 13
  • 17
1

If flutter clean and flutter build apk also generates apk with old version code in your pubspec.yaml change the version like this version: 1.0.2+2 Before + it is your version name and after + sign it is your version code

NOTE: Your new version number should be in the place of 2. Or you can use different format such as 1.2+2

Seymur Mammadli
  • 1,724
  • 15
  • 13
1

You can run flutter clean Then run flutter build apk --split-per-abi to split the apk. It will build three apks and you can find them in build/app/outputs/flutter-apk/

0

enter image description here

Can be done easily by Android Studio

Aman Srivastava
  • 1,007
  • 1
  • 13
  • 25
0

First clean project with command:

flutter clean

Run the command to build the APK:

flutter build apk

The generated APK file(s) will be located in the folder: build/app/outputs/flutter-apk/


You can also specify different options to customize the build process:

  • To build a release APK:
flutter build apk --release
  • To build a debug APK:
flutter build apk --debug
  • To build a release APK with multiple ABIs:
flutter build apk --release --split-per-abi
  • To build an APK for a specific target platform:
flutter build apk --release --target-platform android-arm64
ankushlokhande
  • 870
  • 5
  • 20