Role of classes.dex file in an apk file

Jainendra picture Jainendra · Jan 9, 2013 · Viewed 58.5k times · Source

When opening the apk file with winrar(s/w to open compressed files). I got a bunch of files packed inside the apk. Among them classes.dex is one. My question is what is the role of this file and if we modify/delete the same file will it effect the apk?

Answer

Sahil Mahajan Mj picture Sahil Mahajan Mj · Jan 9, 2013

To make an APK file, a program for Android is first compiled, and then all of its parts are packaged into one file. This holds all of that program's code (These are the .dex files), resources, assets, certificates, and manifest file.

Programs are commonly written in Java and compiled to bytecode. They are then converted from Java Virtual Machine-compatible .class files to Dalvik-compatible .dex (Dalvik Executable) files before installation on a device. The compact Dalvik Executable format is designed to be suitable for systems that are constrained in terms of memory and processor speed.

  • classes.dex: The classes compiled in the dex file format understandable by the Dalvik virtual machine

As the .dex files holds the APK resources, any edit on these files will directly effect the APK.