2
votes

flutter build apk --release

You are building a fat APK that includes binaries for android-arm, android-arm64.

If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size. To generate an app bundle, run: flutter build appbundle --target-platform android-arm,android-arm64 Learn more on: https://developer.android.com/guide/app-bundle To split the APKs per ABI, run: flutter build apk --target-platform android-arm,android-arm64 --split-per-abi Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split Initializing gradle...
1.2s Resolving dependencies... 3.7s registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection) Running Gradle task 'assembleRelease'...

Running Gradle task 'assembleRelease'... Done
140.3s (!)

Gradle task assembleRelease failed with exit code 1

3
Are you creating apk by flutter run --release or by exporting the project in android studio.Ravinder Kumar

3 Answers

3
votes

Try this:

flutter build apk --split-per-abi

Read document for more information

1
votes

Best way I found

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

Over time, android has spread throughout the world and runs on more than 2 billion devices. Because of android running on multiple platforms and foam-factors, it is very important to make sure an optimised app is installed on each platform.

For eg., a phone which doesn't have a high-resolution screen, should not get high-res images and thus reduce the size of the APK.

To make sure your app is optimized for each platform, android provides 2 methods:

  1. You can split your app into multiple APKs optimized for each platform.

    flutter build apk --split-per-abi

  2. Create an app-bundle and deploy it to play store, this way when a user downloads your app, play store automatically extracts and provides the APK which is optimized for that device.

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