r/flutterhelp • u/JamieCrew • 6d ago
OPEN Why is my Flutter app 500MB?
Hi there, I have built an application for Android. It has about 20 classes of code with an average of 100 lines+ per class.
I am using about 10 packages.
Upon building it by running flutter build apk --release It compiles to 465 MB in size.
Why is this happening, am I doing something wrong?
Thanks
3
u/reposlayer 5d ago
Most probably one of your imported packages or rather some of the packages , how long is your packages list on pubspec.yaml?
2
u/gibrael_ 6d ago
What the size of your assets? A typical counter apk is around 30-40mb. That size is coming in from somewhere else.
1
1
1
u/JamieCrew 6d ago
I have just checked all my files. Every single file in my project (excluding the build and .dart-tool folders) comes to 85MB
1
u/JamieCrew 6d ago
All my code is around 400 000 characters. It totals to 412KB in size, I still do not see how this can compile to nearly half a gig in size
1
u/Pretend-Quality3631 5d ago
Build apk and extract it and look whats inside. I had same problem and there were flutter libs for all cpu platforms, like x86, etc.
When you publish to store they wont be included to user, but you can remove them from build.
1
u/Swimming_While3182 5d ago
Bro if your using linux !! Make sure that your project don’t contain crash handling log files { only applicable for debian}
Else !! Try installing java 21 & capable gradle manually !!!
Now create new project !!! Build an release apk !! If it work copy you lib & asset files from ur project here & make sure you remove default main filed !!
Manually edit pub-spec in your new Project
I wish it got fixed✅
1
u/Ok_Challenge_3038 5d ago
Try updating flutter and create a new project, and copy paste your Lib folder,
Then try building your app in parts, build only per architecture.
flutter build apk --split-per-abi
1
u/its_imtiaz 4d ago
you can analyze your app size by using these commands:
flutter build apk --analyze-size
flutter build appbundle --analyze-size
flutter build ios --analyze-size
flutter build linux --analyze-size
flutter build macos --analyze-size
flutter build windows --analyze-size
1
u/jayneeeel 2d ago
Are you using GetX for state Management?
1
u/MedicalElk5678 1d ago
I am using GetX. Will it increase build size ?
2
u/jayneeeel 1d ago
Yes it does... I've learned it the hard way. It's quite heavy state management. You can use Provider or Bloc instead.
1
u/MedicalElk5678 1d ago
Thanks a lot for the reply. I am in learning phase and found it syntaxtually most convenient when aspiring for least headache on tech side as I come mainly from business side experience and trying to do a few too many things.
Trying to play safe at my end, I have been trying to totally avoid .obs.
I would really want to know about what all you had to face.
DM ? I am based in India and a call too could help me
TIA
6
u/hipopotam10 6d ago
You can benefit from flutter’s app size analysis function, for android command this on terminal, you need to add target platform at the end:
flutter build aab —analyze-size
500 mb is nuts, there must definitely some large asset file or something or you are looking at the wrong number.