Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Role of classes.dex file in an apk file

Tags:

android

apk

When opening an APK file with WinRar (software 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 affect the APK?

like image 568
Jainendra Avatar asked Jan 09 '13 07:01

Jainendra


People also ask

What is classes DEX file in APK?

The classes. dex file is a Dalvik Executable file that all Android applications must have. This file contains the Java libraries that the application uses. When you deploy an application for Android, RAD Studio includes a classes.

What are DEX files are used for?

What is a Dex file? A Dex file contains code which is ultimately executed by the Android Runtime. Every APK has a single classes. dex file, which references any classes or methods used within an app.

What is the function of Dex compiler in Android?

Android developers know that dex compilation is a key step in building an APK. This is the process of transforming . class bytecode into . dex bytecode for the Android Runtime (or Dalvik, for older versions of Android).

What is the function of Dex compiler converts the class files to the DEX file?

The Dex compiler converts the class files into the . dex file that run on the Dalvik VM. Multiple class files are converted into one dex file. The javac tool compiles the java source file into the class file.


2 Answers

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.

like image 63
Sahil Mahajan Mj Avatar answered Oct 12 '22 13:10

Sahil Mahajan Mj


.dex file Compiled Android application code file.

From Android API GUIDES

Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created by automatically translating compiled applications written in the Java programming language.

And yes if you will delete those files it will effect APK.

like image 23
BBdev Avatar answered Oct 12 '22 14:10

BBdev