Huge APK size with Mozilla Android Components - android

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

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.

How to minimize the .apk size in android studio?

I am making a simple video call app by using Jitsi Android SDK after completion when i build my signed APK its size is too big i.e, 101 MB when i check that apk it shows the type .nox apk.
Another problem is when i tried to install that 101MB apk into Mobile it says App Not Installed
for this i checked mobile settings Unknown Sources after that it stick to the same message (App not installed).
this is my App's build.gradle(app) file
Here is my Proguard Rule also and target SDK
and this is the extention of APk file
here is my analyze apk result
How to build reduced Apk which run easily...Please Help me into this i don't know where i am going wrong ??
The main reason for your app to be that big is because of all the native libraries which you have in your project. I guess they are included by Jitsi Android SDK.
I guess you are not creating App Bundle but building directly an apk via Android Studio, that's why all versions of native libraries are included in the same apk.
By using App Bundle format to build your app you should lower a lot your app's size, because it will create apk files only for the specific configurations, so every architecture will have it's own apk with included native libraries for only that architecture.
Once you have the App Bundle file you can create your apk's in order to install to a device using bundletool. With a command like this:
bundletool build-apks --bundle=/PathToMyABB/app-bundle.aab --output=/PathToMyAPKS/my-apks.apks
You can retrieve apk as bundle and convert your images to webp format you are going to save %50 memory area.
First of All You Need to Tinify the Resource images Tinyfy, I suggest you to use this link to tinify your image assets.
The Second thing after the above Step, Convert all Image Assets to Webp Format, in order to convert to webp you need to right click on image asset and then at the Bottom of option there will be optionj convert to webp.
Remove Unnecessary classes and libraries to Reduce the Size.
Apply Proguard Rules to Reduce Size
In Order to remove delete x86_64 you just need to do is, just add this under Android Tag in app level gradle File
splits {
abi {
enable true
reset()
include 'armeabi-v7a'
universalApk false
}
}

Is it possible to take *.so libraries off to expansion files?

I faced the task of reducing the size of .apk file of my android app. My apk size is more then 100MB now and tentatively it will grow. So I consider android app bundle as a temporary solution. .so libraries take the most space in apk and I'd like to take them off to expansion files if it is possible. Does anybody have such experience, and what can you advice to learn to solve this problem?
Reduce the size of your app by moving '.so' files to over-the-air. Follow this link
But this violates the Google Policy
You should:
Remove unused resources(image, layout, lib/dependency)
Turn on shirk resource on build.gradle
Moving something to OTA
Build the App bundle instead of APK

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.

Android APK bigger than I expected

I Build an APK using Android studio and its bigger than I expected. I attached a APK analyze report and it shows lib download file size is 56.6 MB. can anyone suggest a way how can i reduce that lib size.
PS: And can someone explain me what is this lib means? becouse i did't use any libs other than dependency. and as i know those dependency included in classes.dex
Thanks.
Screen shot of the APK analyze :
Since you have the dependency of vlc-android-sdk library which contains large native library (libvlc.so) and is included in the app, your apk size is large.
You can use splits or product flavors for different CPU architectures to include only necessary so files. Or you should use a different library.

Categories

Resources