Wink Saville’s Blog

December 23, 2007

Android – use dx to convert a “.jar” file to a “.dex” file

Filed under: Uncategorized — wink @ 6:53 pm

If you want to use ant with a buld.xml file to one of the operations that needs to be done is to convert a “.class” files to a “.dex”. One way to do this using dx is to convert an entire “.jar” file. The following command converts com.saville.android.debug.jar, a jar file with two classes, Log and Timing, to a dex file:

wink@ic2d1:$ dx –dex –output=classes.dex –locals=full –positions=lines com.saville.android.debug.jar
wink@ic2d1:$ ls -al classes.dex
-rw-r–r– 1 wink wink 3971 2007-12-23 18:50 classes.dex

See dx -help for other parameters, –locals=full and –positions=lines is used because thats what the build.xml file generated by activityCreator.py uses.

1 Comment »

  1. Hi. I cant convert my .class files to .dx file. I dont undrestant dx –help it is very Confusing=
    ” dx –dex [--debug] [--verbose] [--positions=] [--no-locals]
    [--no-optimize] [--statistics] [--[no-]optimize-list=] [--no-strict]
    [--keep-classes] [--output=] [--dump-to=] [--dump-width=]
    [--dump-method=[*]] [--verbose-dump] [--no-files] [--core-library]
    [.class | .{zip,jar,apk} | ] …
    Convert a set of classfiles into a dex file, optionally embedded in a
    jar/zip. Output name must end with one of: .dex .jar .zip .apk. Positions
    options: none, important, lines.

    what’s “debug” “verbose”…what I Write Instead?

    I write your command line in cmd :
    dx –dex –output=classes.dex –locals=full –positions=lines jsdt.jar

    but it says : unknown option: –locals=full

    and again i tried to this cmd : dx –verbose-dump –dex –dump-to=myclass.dump MainApplet.class
    but says java.lang.RuntimeException: MainApplet.class: file not found
    While there

    Are you can explain about the detailes parameters that I know how to use dx?

    thanks

    Comment by sajjad — October 11, 2009 @ 1:29 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress