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.
Related
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
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
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.
Inclusion of Sinch Library in Existing Android App , increases size of final apk. We found it is the .so file that are very large and contributing to increased size of apk. Please provide a way if some one knows through which size of .so can be reduced and then it can be used in Android Application, As a result final apk size would be reduced.
Thanks
all code we have in there needs to be in there. The only think you could do is to makes sliced builds for each Architecture
Inclusion of Sinch Library in Existing Android App , increases size of final apk.
No surprise. All libs you include in your project becomes part of your project (statically linked).
I am definitely a noob at understanding this as of now, I noticed usually that the apk file is much smaller than my Android Projects. How is that happening? Is it always like this? I got this doubt while I was compressing an entire project to zip file, it was showing that the disk size is 128MB...(noticed it then the first time) whereas the actual apk is only 22.4 MB. why is this difference?
An APK is an Android application package file. Each Android application is compiled and packaged in a single file that includes all of the application’s code (.dex files), resources, assets, and manifest file. The APK file is basically a .zip file
Your project contains all of your source files and files used only by the IDE. The apk only contains compiled files which are smaller.
Also, images/resources etc are compressed in the apk.
Android projects (in general) contain source code, which gets compiled to class files that end up in the APK.
Compiled files are smaller than the source code - for example they strip all the comments out of the file (you do include comments in your source files don't you!)
In addition to the other answers, you're probably using something called ProGuard which further compresses your project by shortening field names, removing dead (unused) code, merging classes, and dozens of other tricks.
Check out the FAQ for more about ProGuard.
It has to do with how Android compiles your project. It basically dumps the bulk, compresses the resources, and compiles everything into a simple binary. It will happen with almost every type of programming, your final build will usually be smaller than your total project (unless you include outside sources in your build). There is a lot of bulk in code that get's stripped during compilation.