15

My apk was 13MB and on installation the occupied space is 25MB. However, after making a few changes (adding libraries, creating modules and organizing the app better), the apk size had increased to 14MB while the odex file is now 56MB. Is there any way to determine why the size has increased?

I have a rooted device. So I can use more than the traditional approaches too if there are any. I checked several blogs and forums. All explain the odex-ing and deodex-ing related functionalities.

EDIT : The size of the odex file increases with time. (25MB to 81MB now).

This SO Q/A explains what an odex is, but I cannot find any place which explains how the odex file (for the lack of a better word) grows.

A possible option could be that when an app's resources are used, the app odex files generates more references to keep the launch time constant/faster?

EDIT 2: Since a lot of people are answering this by suggesting me to check my libraries/dependencies and reduce them. I want to stress on the observation that. The file size increases after installing in the next few launches of the application.If it were because of libraries addition,the APK size increases which is totally understandable.The rest of the files(.db,shared preferences etc) increase in size which is expected. What I cannot figure out is why does the .odex increase after it is installed which keeps on increasing after every launch .This increase in size is only for the .odex file.

I have checked these files because I am using a rooted device.

Community
  • 1
  • 1
Droidekas
  • 3,464
  • 2
  • 26
  • 40
  • 1
    try decompiling both apks and check them for size increase – Vivek Mishra Apr 30 '16 at 11:32
  • 1
    Did that.Like I said the apk sizes are same.By decompiling,the classes.jar is similar size too.Its only the .odex files which differ massively in size – Droidekas Apr 30 '16 at 11:58
  • Which device and version of Android are you using? How is the growth evolving over time? Does it continues, is there a stabilization? – cuihtlauac May 03 '16 at 07:39
  • A normal third-party application does not have an odex file. How are you getting the size of the app? From Settings? – Jared Rummler May 03 '16 at 08:30
  • @JaredRummler Like I said,I have a rooted device.So i am checking the details from /data/app/ folder. And every generates an Odex file. The Settings app shows the total space occupied without giving an individual breakup.Its basically the contents of the `com.your.application` folder – Droidekas May 03 '16 at 09:12
  • 1
    @cuihtlauac No it reaches a maximum value after 3~4 application launches.Based on that I can(baselessly) conclude thats its sort of an indexing feature? – Droidekas May 03 '16 at 09:13
  • Do you observe the same growth pattern in other devices/versions? – cuihtlauac May 03 '16 at 09:35
  • Yes,its present across all the devices/platforms(I did not measure and check for pattern consistency) but the increase is substantial across all devices – Droidekas May 03 '16 at 09:39
  • @Droidekas only the apk file resides in /data/app/. Can you list the contents of /data/app/[package-name]-[n]? Personally, I think this is Android counting dalvik-cache and the APK together but you said you aren't getting these sizes from app settings. – Jared Rummler May 03 '16 at 19:40
  • @JaredRummler I mentioned that I am using the `com.your.application-n` folder and that is the contents of that folder. The app settings lists the total size of the `com.your.application-n` folder.I got the breakup from the internal folder contents – Droidekas May 04 '16 at 06:05
  • Do you observe this behavior with release or debug builds? And are you using instant run? – tynn May 06 '16 at 16:11
  • @tynn Release and debug builds.I dont use instant run,its not stable enough right now – Droidekas May 09 '16 at 08:45

4 Answers4

0

It grew because you have added libraries. Maybe you need only 1 function from library, but you have added whole library with a lot of resources and functions, so apk grew. About increasing at time: your program (or library you used) could cache images, network requests, write to database etc, so size of program grows.

Viktor Sinelnikov
  • 1,631
  • 2
  • 16
  • 26
  • Please check the comment on the previous answer.The size increase occurs continuously after the app is downloaded. – Droidekas May 08 '16 at 12:21
  • as I said in answer, your program (or library you used) could cache images, network requests, write to database etc, so size of program grows. – Viktor Sinelnikov May 08 '16 at 12:45
  • YEs but this would occupy the space occupied by the `.db` files or other such folders.This would count as data.Static resources like downloaded images/external databases,even shared preferences etc are stored outside the `.odex` file. – Droidekas May 08 '16 at 12:56
  • And regarding bloated libraries,Proguard strips out unused methods too.So the increase in apk size could not be ebcause of that. – Droidekas May 08 '16 at 12:57
0

I believe it grows as the APK file size grows, basically because of adding libraries, image resources and so on.

You can try shrinking your APK size using ProGuard, maybe then the odex file shrinks too.

Mina Wissa
  • 10,923
  • 13
  • 90
  • 158
  • Like I said,the size *increases with time* _after_ the app is downloaded.The are no libraries/image resources being added after that.So proguard/adding libraries should not make a difference for this scenario – Droidekas May 08 '16 at 12:20
0

try to set shrinkResources true in gralde build file for remove un used resource

Linh Nguyen
  • 1,264
  • 1
  • 10
  • 22
0

The issues is

making a few changes (adding libraries, creating modules and organizing the app better

Now, think of this.

You add different libraries. When the libraries are external or third party libraries, the code is packaged with your apk. But when the libraries are android framework libraries that are available on the device already, they won't get bundled in the apk. But these will be included in the odex files and that is why you see the bloat.

So my assumption here is that the additional modules and libraries you used have a lot of new system libraries. Or the libraries that you used internally utilize system libraries. You could alalyze in this direction by trying to remove or using a minimal version of these libraries and see of the odex file size is impacted.

Explanation in chat

Community
  • 1
  • 1
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
  • Can you see the second edit once.I think that should help explain the situation. – Droidekas May 09 '16 at 12:56
  • that's exactly what i tried to explain. so android libraries which are already meant to be on phone will not be packaged in the apk. but when creating the odex file will get included from the libraries already in the android operating system on device. – Viral Patel May 09 '16 at 13:01
  • third party libraries unike android system libraries are not meant to be on device so those will get packaged in the apk. but not the android system libraries. – Viral Patel May 09 '16 at 13:02
  • If possible share the list libraries and modules with their libraries that you added before you saw the bloat and lets try and assert if my reason is correct. – Viral Patel May 09 '16 at 13:08
  • > so android libraries which are already meant to be on phone will not be packaged in the apk. but when creating the odex file will get included from the libraries already in the android operating system on device., Do you have any official source for that? And as for addition of libraries,its breaking up a large module(app) into 2 modules.thats all was changed – Droidekas May 09 '16 at 13:22
  • And also why does this increase in size happen gradually,and not on the first launch. – Droidekas May 09 '16 at 13:24
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/111438/discussion-between-androidmechanic-and-droidekas). – Viral Patel May 09 '16 at 13:34