Android command line compile, package build apk file

Source: Internet
Author: User

First, build the environment

1. Installing the JDK and Android SDK2. Configure environment Variables D:\android-sdk-windows\tools C:\Program files\java\jdk1.6.0_20\bin
3. Example Information project directory: D:\ProjectDemo SDK Directory: D:\android-sdk-windows\platforms\android-8\
Second, the command line to compile the Android project
1. Generate R file 2. Java code generates class file 3. class file generates DEX file 4. Packaging Resources 5. Generate Apk6. Create key 7. Signature APK 1. AAPT command, generate R file
> aapt package-f-m-j/gen-s res-m androidmanifest.xml-i D:\android.jar
-F If the compiled generated file already exists, force overwrite. -M causes the directory of the generated package to be stored in the directory specified by the-J parameter-j specifies the output directory path of the generated R.java-s specify the path to the Res folder-i specifies the path to the Android.jar file for a version of the platform-a specifies the path of the Assert folder 2. Javac command, generate class file
> Javac-target 1.5-bootclasspath D:\android-sdk-windows\platforms\android-8\android.jar-d bin src\demo\project\* . Java Gen\demo\project\r.java
-target < version > generate class file for a specific VM version-bootclasspath < path > Overwrite the location of the boot class file-D < directory > Specifies the location where the generated class file is stored-sourcepath < path > Specify the location to find the input source file

3. DX command, convert class file to. dex File
> DX--dex--output=d:\projectdemo\bin\classes.dex D:\ProjectDemo\bin
--output=< the Classes.dex path to be generated > < path to the class file to be processed >

4. AAPT command, Packaging resources
> Aapt package-f-M androidmanifest.xml-s res-i D:\android-sdk-windows\platforms\android-8\android.jar-F Bin\resou Rces.ap_
-F If the compiled generated file already exists, force overwrite-m to specify the path of Androidmanifest.xml-S to specify the Res folder path-i specifies the path of a version of the platform Android.jar-f Specifies the output file full path 5. Apkbuilder command, Generate APK
Apkbuilder D:\ProjectDemo\bin\projectdemo.apk-v-u-z D:\ProjectDemo\bin\resources.ap_-F D:\ProjectDemo\bin\ CLASSES.DEX-RF D:\PROJECTDEMO\SRC
-V Verbose Show process information-U create a unsigned package-Z to specify the APK resource path-F to specify the Dex file path-RF Specify the source path 6. Create key
>keytool-genkey-alias release-keyalg rsa-validity 20000-keystore release.keystore
-genkey creates a default file ". KeyStore" in the user's home directory, and also generates an MyKey alias, MyKey contains the user's public key, private key, and certificate-alias the algorithm that generated the alias-keyalg the specified key-validi TY specifies how many days the certificate is created-keystore specifies the name of the KeyStore (the resulting types of information will not be in the. keystore file)

7. Signature
Jarsigner  -verbose-keystore C:\Users\UserName\Desktop\build\release.keystore-storepass antmima-keypass Antmima-signedjar D:\ProjectDemo\bin\projectdemo-signed.apk D:\ProjectDemo\bin\projectdemo.apk Release
-verbose signature/Validation output details-keystore keystore location-storepass password for KeyStore integrity-keypass private key password (if different)-signedjar The name of the signed JAR file (the first apk is the file after the signature, and the second apk is the one that needs to be signed)

Android command line compile, package build apk file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.