Hybrid Application Sizes - flutter

Currently, I've been developing an application in flutter but after I install it on my android device I diagnosed that it takes huge amount of space.
Firstly I want to know if there is any solution to it?
Secondly, if there isn't any solution; is there any other hybrid language without this problem??

if you run flutter run and see the application size in your phone you will find it very large > 40 MB. This is because while in debug mode whole flutter engine is installed on phone to support debugging and Just in time compilation of your dart files. Effectively lets you hot reload your changes Just in time.
Now if you run flutter build apk or flutter run --release, this will generate an apk in release mode. Means no debugging support, everything Ahead of compiled to target machine code. And the size of the app should be as low as possible < 15 MB.

Related

My Apk size getting much large after upgrading flutter to latest

Im building an apk and the size is too large bcz i just created a ui till now and the size is 49mb there is huge differnece .
in this image the upper apk size is 22mb which build is created 7months ago but now i reopen and just created build again the size is 47mb somehow facing this issue in all apps the size is getting larger.
Try with flutter released apk .
I also came across in this very apk condition when debugging, while in releases around 7-8 mb. This however we could see it in much larger apps, where natively speaking, we need to import many libraries, while with Flutter the work is optimized. So if we assume an app that natively should weigh around 30mb with Flutter it should be similar. What can scare you is in the very basic apps. The important thing however is to optimize the images.
After running flutter build apk --release, my APK size was 16.2 MB. This APK is called FAT APK which is a single APK that contains binaries for multiple ABIs embedded within it and supports multiple architectures. With flutter build apk --split-per-abi, dart code obsfucates resulting in 3 APK files, size of my app.APK was reduced to 5.6 MB.

Flutter run in vscode taking unexpectedly long time

I am using vs code for flutter dev for the first time, while trying to run the app, it's showing me "this is taking an unexpectedly long time".However it builds the application, but takes around 17 mins. Any help??
So, I am a Windows PC user with 4GB RAM and i3 processors. I know the thing you're thinking. "Why is it taking so much time?" Believe me, I go through it a lot. Actually, it is not your fault or Flutter's. It is because of the slow PC.
Usually, the 1st run takes time. It has to build packages and stuff. So, it will take time. After the first build, as and when, new dependencies are added, the run time may increase. But after the first build, it runs faster.
Another issue I've found when building Flutter apps onto a physical Android device specifically, is that ADB may be causing the slow performance.
So running:
adb kill-server
Then unplugging and replugging the device and then:
adb start-server
Followed by:
flutter run
Increased performance
I am a windows user. My pc has a core i5-4200u(2 cores, 4 threads) with only 6GB ram.
If you are trying to run the app in an android emulator or in an android device try this.
Add following lines to the gradle.properties file found in your android folder in your project directory.
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true
Checkout these 3 links for more information
https://www.journaldev.com/12333/increase-gradle-build-speed
https://medium.com/#AthorNZ/how-to-speed-up-your-slow-gradle-builds-5d9a9545f91a
https://www.youtube.com/watch?v=7ll-rkLCtyk
Earlier I had build times like 200s or more. But after enabling these features my build times got significantly lower.
In the first run you won't notice a massive difference. But after that your build times will reduce massively.
After doing all this I got like 40s or less build times.
The build time without the changes mentioned above
The build time in the first run after the changes
The build time in the second run after the changes
Please note that I have only changed the gradle.properties file to improve build times.

Flutter release apk

I would like to know if the apk file produced from running the flutter run --release command is different from flutter build apk. Which is better for uploading to the playstore.? I just tried both commands and the difference in apk size is really huge. The release command produces a far smaller apk size.
In summary what I want to know is since
Flutter build apk =>> fat apk.
Does
Flutter run --release =>> split apk?
flutter run --release: builds a release version of the app and starts it directly, then shows the console UI to manipulate the running instance.source flutter wiki
Use release mode for deploying the app, when you want maximum optimization and minimal footprint size. For mobile, release mode (which is not supported on the simulator or emulator), means that:
Assertions are disabled.
Debugging information is stripped out.
Debugging is disabled.
Compilation is optimized for fast startup, fast execution, and small package sizes.
Service extensions are disabled.
(apps are smaller)
flutter build apk results in a fat which is a single APK that contains binaries for multiple ABIs embedded within it. This has the benefit that the single APK runs on multiple architectures and thus has wider compatibility, but it has the drawback that its file size is much larger, causing users to download and store more bytes when installing your application. When building APKs instead of app bundles, it is strongly recommended to build split APKs
Although app bundles are preferred over APKs, there are stores that don’t yet support app bundles
When should I build app bundles versus APKs?
The Google Play Store recommends that you deploy app bundles over APKs because they allow a more efficient delivery of the application to your users. However, if you’re distributing your application by means other than the Play Store, an APK may be your only option.
read more from the docs
You can split apks with this command
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi

Publish Flutter to google play 64 bit issue

I am trying to close test a flutter app but I keep getting the error ----
"This release is not compliant with the Google Play 64-bit requirement
The following APKs or App Bundles are available to 64-bit devices, but they only have 32-bit native code: 21.
Include 64-bit and 32-bit native code in your app. Use the Android App Bundle publishing format to automatically ensure that each device architecture receives only the native code it needs. This avoids increasing the overall size of your app. Learn More"
I tried building it in 64 and 32 bit apk's and uploading them per this article - https://medium.com/#truongsinh/flutter-android-64-bit-so-what-the-fuss-15da6f8e3a46
but its still throwing the error. Whats the solution for this?
You can use codemagic and forgot all the things about upload your app to Google Play or AppStore manually

Is there a way to download the crosswalk runtime after the app has been installed on android?

Compiling an app with crosswalk through cordova would increase the size of the app by approximately 20 Mb.
So, I was thinking if downloading and running code on crosswalk runtime after the application is installed would work. If this works then I would download and use crosswalk runtime on certain Android platforms (< Android 4.4.3) only. And use webview on remaining platforms. Just want to avoid building two different apps with same code for different platforms.