Android 'dx' tool

Liz picture Liz · Dec 13, 2011 · Viewed 32.9k times · Source

Is there any documentation for 'dx'?

In particular, I am interested in knowing what the --core-library option does.

Answer

Durai Amuthan.H picture Durai Amuthan.H · May 29, 2014

What is the 'dx' tool?

The dx tool converts Java class files into a *.dex (Dalvik executable)* file.

Where is it?

The dx.jar file was original located under android-sdk/platforms/android-X/tools/lib/ before (especially in Android 3 and Android 4) and was moved to android-sdk/platform-tools/lib/ later.

How does it fit in Android?

The Java source files are converted to Java class files by the Java compiler.

The dx tool converts Java class files into a *.dex (Dalvik executable)* file. All class files of the application are placed in this .dex file. During this conversion process redundant information in the class files are optimized in the .dex file.

For example, if the same String is found in different class files, the .dex file contains only one reference of this String.

These .dex files are therefore much smaller in size than the corresponding class files.

The .dex file and the resources of an Android project, e.g., the images and XML files, are packed into an .apk (Android Package) file.

To understand better, look at the Android build process:

Build process

FYI:

The program AAPT (Android Asset Packaging Tool) performs APK creation. The resulting .apk file contains all necessary data to run the Android application and can be deployed to an Android device via the ADB (Android device bridge) tool.

Reference