"dx.bat --dex" Command - Converting .class Files into .dex File

This section describes the 'dx.bat --dex' command that can be used to convert Java byte code (.class) files into a Dalvik executable (.dex) file.

The next tool used in the "ant -verbose debug" command is the "dex" tool, which converts Java byte code into a .dex (Dalvik Executable) file.

Looking at the output of "ant -verbose debug", I have created this "dx.bat --dex" command to perform the byte code conversion step of the build process. The dx.bat calls a Java application to do the actual conversion work. This is how the command works on the HelloAndroid project:

C:\herong\HelloAndroid>
   \local\android-sdk-windows\build-tools\22.0.1\dx.bat --dex   
   --verbose --output .\bin\classes.dex    .\bin\classes   

processing ...\bin\classes\com\herongyang\BuildConfig.class...
processing ...\bin\classes\com\herongyang\HelloAndroid.class...
processing ...\bin\classes\com\herongyang\R$attr.class...
processing ...\bin\classes\com\herongyang\R$drawable.class...
processing ...\bin\classes\com\herongyang\R$layout.class...
processing ...\bin\classes\com\herongyang\R$string.class...
processing ...\bin\classes\com\herongyang\R.class...

C:\herong>dir \herong\HelloAndroid\bin\classes.dex

      2,328 classes.dex

I think the command worked correctly. All *.class files are converted into a single .dex file: classes.dex.

Last update: 2015.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows System

 Installation of Android SDK R24 and Emulator

 Installing Apache Ant 1.9 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 Android 4.0.3 File Systems

 AboutAndroid - Application to Retrieve System Information

 android.app.Activity Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

Build Process and Package File Content

 "android create project" Command Options

 Android Project Folder Structure

 Android Application Project Build Process

 Project Build Process Done by "ant debug" Command

 Detailed Output of "ant -verbose debug" Command

 Output of "ant -verbose debug" - Android SDK R17

 "aapt" - Android Asset Packaging Tool

 "aapt package" Command - Resource Code Generation

 "javac" - Java Compilation Command

"dx.bat --dex" Command - Converting .class Files into .dex File

 "apkbuilder" Command - Packaging and Signing .apk File

 "zipalign" Command - Aligning File Locations in .apk Package

 "aapt dump" Command - Printing Contents of .apk Package

 META-INF Files - Digests, Signature and Certificate

 Building Your Own Web Browser

 Android Command Line Shell

 Samsung Galaxy Tab 3 Mini Tablet

 USB Debugging Applications on Samsung Tablet

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 Android Phone - LG-P925g

 USB Debugging Applications on LG-P925g Phone

 Outdated Tutorials

 References

 PDF Printing Version