Search code examples
flutterdartapkversion

Flutter release apk size is very large in flutter sdk version 1.20


I am making a very simple app with 15 screens. And when i run this command flutter run --release. My release apk size is 26.2mb, which is very large.

My flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.2, on Linux, locale en_US.UTF-8)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
[✓] Android Studio (version 4.0)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

My pubspec.yaml file contain these dependencies:

  cupertino_icons: ^0.1.3
  flutter_svg: ^0.18.0
  provider: any
  image_picker: ^0.6.7+4
  menu_button: ^1.2.1
  pin_code_fields: ^5.0.1
  flutter_pdfview:
  path_provider:
  http:

github

These files takes the more space. Is there any way that we can reduce the release apk size. For apps like this, the size is very large. In my previous flutter sdk version 1.17 the release apk size of 30 screen app is not more than 15 mb.


Solution

  • From your screenshot what is shown is the size of the appbundle (created for all android platforms) which is the total of all apk (for all android platform) and not size of a single platform apk. The reason is flutter run --release by default will build the appbundle which is the recommended way to build appbundle when you upload to playstore. Playstore will generate the apk for each device separately for download (arm64-v8, armeabi-v7a and x86_64).

    So in your case, to generate a proper apk for size measurement, run:

    flutter build apk --target-platform=<YOUR_TARGET_PLATFORM>
    

    or this (will generate 2 APKs)

    flutter build apk --split-per-abi
    

    for more details please refer flutter.dev: Android App Size and flutter.dev:Build Modes