why flutter project files size is more then 500MB? - android

Is it normal the size of flutter start app "counter app" is 125MB on Android Device, also the project files size is 543MB, the build file only is 508MB, I have a problem if anyone can help?

Flutter team acknowledges it
https://github.com/flutter/flutter/issues/12456.
There's an explanation for this https://flutter.dev/docs/resources/faq#how-big-is-the-flutter-engine,
In August 2018, we measured the size of a minimal Flutter app (no Material Components, just a single Center widget, built with flutter build apk), bundled and compressed as a release APK, to be approximately 4.7MB.
For this simple app, the core engine is approximately 3.2MB (compressed), the framework + app code is approximately 840KB (compressed), the LICENSE file is 55KB (compressed), necessary Java code (classes.dex) is 57KB (compressed), and there is approximately 533KB of (compressed) ICU data.
Of course, YMMV, and we recommend that you measure your own app, by running flutter build apk and looking at build/app/outputs/apk/release/app-release.apk.
Also, the relative differences in apk size would likely be smaller with larger apps. Flutter's overhead size is fixed.
1)For reduce the size you can use.
flutter clean
2)flutter build appbundle --target-platform android-arm,android-arm64
3) you can use proguard to reduce the size
Here is Official Android documentation that made my apps go From ~20mb To ~9mb
Try the Proguard recommendation
Link: https://developer.android.com/topic/performance/reduce-apk-size

Related

How to decrease flutter app size in android

I make my app using flutter and my app size is more than 100 mb and app has 15 screens.
It's android size is more than 100 mb and iOS app size is 40 mb I have to make it small
and I want proper solution for this


I try to compress my image files but it just decrease 8 mb
I want proper solution for compress flutter app size.
Check this below steps it may help you to reduce app size (only Android), i have reduced my 48mb build to 14mb
Step 1: android/gradle.properties
android.enableR8=true
Step 2: android/app/build.gradle
inside -> buildTypes -> release
minifyEnabled true
shrinkResources true
useProguard true
Step 3:
Run
flutter build apk --target-platform=android-arm
or
flutter build apk --split-per-abi
Some other optimizing tips,
1. Image assets
Upload the images in permanent storage path like AWS or in your website server and use the link to that image in your code.
2. Icons
Its recommended to use from Material Icons or Cupertino Icons class. You can add --tree-shake-icons option to flutter build command, to remove all of the not used icons from the bundle. This will potentially save the size of your app. (use svg format icons)
3. Fonts
If we are using more fonts from local assets similar like images these fonts will also increase app size. The best solution is to use google_fonts plugin. This pluign will dynamically download font when it is used.
4. Dynamic App Delivery
We could build an app bundle if we are uploading to playstore or we could split the apk per abi which splits the apk to x64 and x86 bit code. By using appbundle Google Play’s new app serving model, called Dynamic Delivery, uses your app bundle to generate and serve optimized APKs for each user’s device configuration, so they download only the code and resources they need to run your app.
Refer below links for more understanding,
https://developer.android.com/studio/build/shrink-code
https://developer.android.com/guide/app-bundle
https://www.youtube.com/watch?v=9D63S4ZRBls
How many third-party packages are you using?
Did you use drag and drop to create the app or code everything manually?
Did you properly use const in objects that are repeated but are essentially the same? Like const EdgeInsets.all(8.0).
Do you have a lot of gradient images that you can convert to Container gradients?
Use webp images instead of PNG or JPEG
Add pro-guard files
Minify Enabled - true
Shrink- Resource -true
try running:
flutter clean
and then:
flutter build apk --split-per-abi
you could even further reduce the size of your code by doing:
flutter build apk --split-debug-info=/<project-name>/<directory>
and if you're willing to take the risk, you can obfuscate your code:
flutter build apk --obfuscate --split-debug-info=/<project-name>/<directory>
where
/<'project-name'>/<'directory'>
is the directory where Flutter can output your app debug files.

Huge APK size with Mozilla Android Components

I'm building an APK (not app bundle) using Gradle via Android Studio.
Without adding any Mozilla dependencies in my app's build.gradle file the APK size is under 5MB but after adding these dependencies the APK size increases to over 100MB.
Most of the APK size is in the (new) lib directory, particularly the lib/libxul.so file, but also the assets/omni.ja file is around 9MB.
I am aware of how to reduce the APK size by using ABI filters and APK splitting to generate separate APKs for different architectures, but this can only do so much to reduce the download size for the user. Is there any way I can significantly reduce the size of my APK? Are there any command line options I can add or additional Gradle options to achieve this?
For reference, I am importing the following dependencies: https://github.com/mozilla-mobile/android-components
from here: https://maven.mozilla.org/maven2
The official recommendation is here: https://developer.android.com/studio/build/shrink-code.
And you can also use Play feature delivery to serve some features only when needed by users: https://developer.android.com/guide/app-bundle/play-feature-delivery

Using FFmpegMediaPlayer - Apk size increased by 35MB approx - (without library apk size - 4mb)

Is there a workaround to this, as the size of the apk is drastically increased and the library was added through normal procedure -
(compile 'com.github.wseemann:FFmpegMediaPlayer:1.0.4')
and not through manual inclusion or downloading I wonder whether anyone else has this problem.
if you go to the source code of the library, to the releases page (https://github.com/wseemann/FFmpegMediaPlayer/releases) you'll see that you can manually download to your PC, what is normally being downloaded by gradle and then added to your APK.
There you can see it's 50mb zip, file so it's not crazy to imagine 35mb increase in the APK.
That's because it's not a half dozen Java files, like most libraries are, but this have the compiled binary code of the FFMPEG, compiled for each platform Android uses (arm, x86, 32 and 64bits).
So yeah, final conclusion, if you're really gonna use any ffmpeg based thing, your app will take this extra space.

Does Dagger 2 Increase the APK Size?

How much size does Dagger 2 increase the android apk? As proguard removes unused methods, how do you track the actual increased size?
Open Android Studio, and go to File > Profile or Debug APK. From there you explore your APK and get a breakdown of what parts are contributing what to the total APK size.

Cocos2d-js: projects need to be that huge?

I'm trying out cocos2d-js (version 3.0) and even the simplest 'Hello World' project is over 1 gigabyte in size when it is created.
Is this normal? (I have a habit of creating dozens of demo-projects when trying out a new platform, but it looks like I need to get myself a bigger SSD, just for this!)
Also, the size of the apk, when compiled for Android, is about 9 MB. Any ways to reduce this size?
Sadly, yes. I've mentioned this in the community a couple of times to no avail. I believe this files should be referenced/cached in a common location for all projects, but the dev team seems to have other priorities at present.
If you wish to keep your projects you'll be better off heading to their frameworks directory and deleting all folders except cocos2d-html5 (this one should be 5MB only) in there. -
An alternative would be to also delete the cocos2d-html5 folder, place it in a common dir (or use the copy in your install folder) and reference the path properly in your projetc's config file. Keep in mind this option may break code suggesstion/autocomplete in some editors, and throw errors in your webserver when you try to run the project.-
This way, you'll be able to run any of those projects in the browser, and then only add the files neccessary for native compilation in projects you wish to test in the emulator or your device (or compile for publishing). This will sadly take a lot of time to copy and re-generate the files, of course.
As for reducing the size of the .apks... I don't know a way. I know efforts are being made to optimize the binder, and there may be a way to explicitly avoid packaging unused stuff, but I don't know about it.
You can reduce the app size in Cocos2d-js v3.2 released in January. It allows you to exclude the unused modules. Refer to the upgrade guide for more details on how to do this. The minimum apk size for Android is 4.4mb .

Categories

Resources