I recently added the following packages to my Flutter project:
dependencies:
sqflite: ^2.3.2
path: ^1.8.3
Since adding these packages, I’ve noticed that my APK size has increased by approximately 100 MB, bringing the total size to around 200 MB. This is a significant increase, and I’m concerned about the impact on app performance and user experience.
What I Have Tried:
-
Run
flutter clean
: Cleared build artifacts and cached files. -
Clear Flutter and Gradle Cache: Used
flutter pub cache repair
and deleted.gradle
caches. -
Analyze APK Size: Attempted to analyze the APK size but faced issues with specifying a single ABI.
Questions:
-
Is it common for the
sqflite
andpath
packages to cause such a large increase in APK size? -
What are the possible reasons for this substantial size increase after adding these packages?
-
What additional steps can I take to further investigate and reduce the APK size?
Any guidance or suggestions on how to resolve this issue would be greatly appreciated.
Thank you!
2
Answers
I am not sure about sqflite and path. But here are some tips to cretae apk a bit lighter.
this will create apk in release.
I hope this work for you.
To decrease the size of an APK in a Flutter app, follow these steps:
1. Remove Unused Dependencies
pubspec.yaml
file and remove any unused dependencies. Every additional package adds code to your APK.2. Enable ProGuard for Android
android/app/build.gradle
, set theminifyEnabled
option totrue
for the release build type:3. Shrink Resources
build.gradle
:4. Use Split APKs by ABI
app-armeabi-v7a-release.apk
,app-arm64-v8a-release.apk
, etc.).5. Remove Debugging Information
6. Use Flutter Build for Tree Shaking Icons
7. Optimize Images
8. Avoid Using Large Fonts
9. Use R8 Instead of ProGuard
By following these steps, you can reduce the size of your Flutter APK efficiently.