Address: http://www.eoeandroid.com/thread-25121-1-1.html
Today, I have developed a tool for packaging APK. I will share with you the example and upload it as an attachment for your reference. I hope this will help you.
The attachment contains two bat batch processing files. I will explain the commands here and share them with you.
Content of the createdex. BAT file:
Aapt package-m-J Src-M androidmanifest. XML-s res-I android. jar // This command is mainly used to automatically generate the R. java files, such as adding images or strings or adding XML files in the layout directory
Mkdir D: \ testapk \ Classes // This command creates a directory for compiling *. Java source file output *. class. The folder name can be named at will.
Javac D: \ testapk \ SRC \ aimoxiu \ theme \ moxiutheme \ *. Java-classpath D: \ testapk \ Android. jar-D: \ testapk \ Classes \
// This command calls the javac tool to compile the source code. Therefore, make sure that the JDK has been installed on the target computer. The output directory is the one just created.
Cd d: \ testapk \ Classes
Jar CVF aimoxiu. jar *. * // This command is to compress the *. Class file in the Directory into a jar package, in order to create the classes. Dex file required by the APK later
CD ..
DX -- Dex -- output = classes. Dex D: \ testapk \ Classes \ aimoxiu. Jar // This command converts the jar package to the DEX file that can be run on the Android phone.
Content of the createapk. BAT file:
Aapt package-z-u-X-F-M androidmanifest. XML-s res-I Android. jar-F moxiu.apk // This command generates the application APK File
Aapt add moxiu.apk classes. Dex // This command compresses the previously generated classes. Dex file to the APK file, and finally generates a runable APK Application
Java-jar signapk. Jar aimoxiu. x509.pem aimoxiu. pk8 moxiu.apk moxiu_theme.apk // The command automatically signs the generated APK, And the unsigned APK cannot be installed. So an Android Application APK is finally released!
Del moxiu.apk/Q // Delete the generated unsigned APK File
For Windows operating system implementation, you do not need to use the eclipse tool to compile and package the APK program. I have passed the test and the generated APK file can also be run on the android real machine. For the tool, see the attachment.