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
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
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.
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.
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 .
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.