classes.dex

Kevin

Well-Known Member
Licensed User
Longtime User
Just curious exactly what is in the classes.dex file when an app is compiled.

I decided to clean up my code today and primarily I changed about 70 single Dim lines such as

Dim Button1 as Button
Dim Button2 as Button


to

Dim Button1, Button2 as Button

I also removed maybe 3 or 4 Dim XX as YY statements on variables that my project no longer uses. Other than that, I made no other changes other than add about 20 lines of code to add some new functionality to the app.

I figured that changing the way I did my Dim statements might reduce the code size a little, but was shocked to see that my APK was a little over 100kb smaller. Curious, I looked into the APK and compared it to an APK that I made before the changes and saw that the only thing that had changed was the classes.dex file, and that uncompressed, it was actually over 300kb smaller now!

What did it? Does dimming multiple variables in 'shorthand' save that much space in the classes.dex file, or was it simply from removing just a few unused variables? If that's the case, then does dimming a single variable add that much size to your app?

Mostly just wondering. I was so surprised in the size reduction that I initially feared that I accidentally deleted several blocks of code! As best as I can tell though, it's all still there.
 

Kevin

Well-Known Member
Licensed User
Longtime User
No, it wasn't debugging information. I did check that and it only made a difference of about 30kb (compressed) I believe.

One other thing I did that I had forgotten was I had hit Tools>Clean Project, but I wouldn't imagine that would affect the classes.dex file, but I don't know Java.

Now I'm worrying again that I somehow deleted a bunch of stuff, yet I've tried every function in my app and it all seems to work fine.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User

That must have been it then, because I definitely have done all of the above. I just got done comparing my new project to the older one line by line (due to my paranoia) and didn't see any differences other than the new code I added and that it was about 200 lines shorter now after re-doing the Dim statements and removing a bunch of white space. I wouldn't have thought that would make a huge difference (and apparently it doesn't) if not for the fact that my project had mysteriously shrank.

I will have to remember to clean my project more often! To me, 100kb is quite substantial in an APK.

Thanks for clearing things up! :sign0188:
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…