I have searched extensively on the web for a comprehensive guide to creating an Android DEX file (Java Dalvik bytecode) using the Android SDK DX tool.
My aim is to create a Jar file that contains DEX byte code which can be loaded by an application at runtime.
To create the Jar file I have been following these steps:
- Java source code containing a public class (Name.java)
- Compile .java file from step 1 into .class file using
javac Name.java
- Created a Jar file from the class file.
jar cvf output.jar name.class
- Use the dx tool to convert class file into classes.dex.
./dx --dex --output=classes.dex output.jar
- Use aapt to repackage the classes.dex file with the jar file.
So far I have managed to make it to step 4, which is where I am experiencing issues. When running the dx tool, I get the following error:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.io.FileNotFoundException: /home/del/Desktop/AndroidJarBuilder/output.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:215)
at java.util.zip.ZipFile.<init>(ZipFile.java:145)
at java.util.zip.ZipFile.<init>(ZipFile.java:159)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
1 error; aborting
I wonder if anyone has experienced this problem before, i could not find any answers on Stack Overflow, and the rest of the web did not provide me with any solutions.
Thanks in advance.