Friends I have a problem, the detail is when I generate my apk it comes weighing around 6 MB, so far everything is fine, when installing it on devices the size of it extends considerably already installed it manages to occupy 18 MB of space in another 36MB and another 8MB, my question is, what is it due to? Why doesn't it maintain a fixed size on all devices when installed? since it does not contain much code and resources.
How large an app will be when installed on a device depends on several factors.
When the application is installed, a copy of the
apk
en is created/data/app
.Subsequently, a compiled and "optimized" DVM version is generated
/data/dalvik-cache
with an extensionodex
(optimized dex) or in modern versions of Android, ART , libraries, etc. are used.The size of the optimized file generated by the DVM and ART version depends on the Android version, the hardware platform (ARM, x86, x86_64, etc), etc, so you cannot have control over it or calculate it in a single way.
The .apk can vary in size when installed on a device for two main reasons:
As for code optimization to reduce size, it is a good option to use Proguard or Dexguard (although there are other options).
To reduce the size, you may have seen inside your file
build.gradle
the property:I recommend you read this article:
Reduce your code and resources