Android's Dex Class Structure

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Android's Dex Class Structure

Postby plusminus » Fri Nov 16, 2007 11:25 am

This is a collection of source concerning the *.dex file-structure that runs on the Dalvix VM...

:arrow: Detailed Analysis of the Dex File Format

If you've been paying attention to the tech news lately you might have heard about a little something called Android from Google. Android is a new mobile phone platform based on Linux and Java, but unlike other Java platforms Android uses a non-standard JVM called Dalvik. While Google has promised to release much (all?) of Android under an open source license, they haven't done so yet and they also haven't released any documentation on this new VM. Being somewhat impatient, I've taken it upon myself to do some reverse engineering and put together some documentation of my own. This page documents the Dex file format that compiled programs get translated into for use on the Dalvik VM. I hope to write some documentation on the VM itself in the near future.

File Header
Dex files start with a simple header with some checksums and offsets to other structures
Code: Select all
[*]Offset    Size    Description
[*]0x0        8    'Magic' value: "dexn009\0"
[*]0x8        4    Checksum
[*]0xC        20    SHA-1 Signature

Read full Article on ''

:arrow: Read full Article on 'Shane Isbell's Weblog'
Shane Isbell's Weblog wrote:Android's Dex Class Structure

I couldn't find the specs for the Dex class structure, so I have been poking around. I am blogging about what I have found as a starting point for other people to start their own investigation, this is no replacement for an actual spec from Google, it is still incomplete and parts may be inaccurate.

The dex class structure is remarkably similar to the Java class structure but with some notable differences:

1. Dex classes use little-endian encoding, while Java classes use big-endian encoding.
2. An Android package contains one large dex class. Note that the field_id and the method_id reference a class_index so there are multiple Java class references within the dex class (although they are no longer true Java classes).
3. Dex classes make strong use of offsets, while Java makes use of tags.
4. It appears that the single dex class is significantly smaller than the total size of the Java classes: 1800 bytes versus 2500 bytes in one case. This would certainly help to decrease download time for apps, a good thing for wireless devices.

The class structure is as follows:

Code: Select all
     8 magic

Read full Article on 'Shane Isbell's Weblog'

Image | Android Development Community / Tutorials
User avatar
Site Admin
Site Admin
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany


Return to General

Who is online

Users browsing this forum: No registered users and 7 guests