App size differs in different Android versions

I was reading a lot about different application sizes after installation. EG: Why apk size increase in different android version

But something I still do not understand. I have an application (com.onhost.skuska made in LibGDX) and on Android 4.3 . immediately after the installation (eg with no extra data) it takes 17.54 MB and on Android 5.0 , Galaxy S6 it takes 30.73 MB .

At first I thought it is about different hardware or screen resolution. I have tried to install the app on Genymotion emulator of S4 with Android version 4.3 and it was more or less 17.5 MB. When I installed the application on my S4 with Android 5.0 the app size after installation increases to 29.21 MB.

I have investigated actual files (using find -name "skuska" on terminal) after installation. On Android 5.0, Galaxy S6 (Genymotion) the main folders and files are these:

  • file, 22 MiB, /data/dalvik-cache/x86/data@app@com.onhost.skuska-1@base.apk@classes.dex
  • folder, 912 KiB, /data/data/com.onhost.skuska/lib/ containing:
  • file, 668 KiB, libgdx-freetype.so
  • file, 244 KiB, libgdx.so
  • folder, 8.8 MiB, data/app/com.onhost.skuska-1/ containing:
  • file, 8120 KiB, base.apk
  • folder, 920 KiB, lib/x86/ containing again: libgdx-freetype.so and libgdx.so
  • Files on Android 4.3 are as follows:

  • file, 8924 KiB, /data/dalvik-cache/data@app@com.onhost.skuska-2.apk@classes.dex
  • file, 8120 KiB, /data/app/com.onhost.skuska-2.apk
  • folder, 912 KiB, /data/app-lib/com.onhost.skuska-2/ containing:
  • file, 668 KiB, libgdx-freetype.so
  • file, 244 KiB, libgdx.so
  • As we can see the main difference is in the .dex file. I would like to ask you if there is any way how to make size of .dex file the same as on Android 4.3? Or why there are two times *.so files in Android 5.0?

    Thank you very much for any suggestion to solve this issue.

    EDIT: I do use Proguard for shrinking (no optimisation or obfuscation). EDIT 2: I also checked some other apps not programmed in LibGDX and their 5.0 version is bigger but not so dramatically.


    The reason they are different sizes is because Android 5.0 has additional features which are included in the classes.dex for compatibility reasons (even if you're not using them). This is also sometimes called boilerplate code. Also, if you have two different installations that are both signed differently but that use the same app name (com.onhost.skuska) then android will install both of them, and not overwrite the first one, and instead add a -1 to the end (com.onhost.skuska-1) etc.

    /data/dalvik-cache/x86/data@app@com.onhost.skuska-1@base.apk@classes.dex is a cached file and is used to speed up the loading of commonly used applications so that the apk file doesn't have to be extracted each time.

    链接地址: http://www.djcxy.com/p/66916.html

    上一篇: 为什么Redmi手机(MIUI手机)的应用程序大小更高?

    下一篇: 应用程序大小在不同的Android版本中不同