Use the command line to simulate the Android Project compilation process in Eclipse (compile the final apk from the source code)

Source: Internet
Author: User

References.

1. Android Projectd Building System


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + signature + 3zwvcD4KPHA + signature/Signature/WztLPwtTYtcTUtMLrxL/CvM/Signature + signature + PGJyPgo8L3A + signature + Signature = "http://www.2cto.com/uploadfile/Collfiles/20140401/20140401092726118.png" alt = "\">

At this time, the gen directory has no content, and the bin directory is not displayed in the project directory. However, you can view the content on the terminal as follows:

NO content in the classes folder

2. Right-click and Build the Project. The directory structure is as follows:


In this case, the R. java directory is generated under the gen directory, and the bin directory is displayed in the project directory. There is no content shown above. However, the content is changed on the terminal, as shown below:

Only one classes folder is left. This folder is empty.

Corresponding command:

Run the following code in the project directory:

Generate the R file:

Aapt p-f-m-J gen-S res-I ~ /Android-sdk-linux/platforms/android-18/android. jar-M AndroidManifest. xml


3. Right-click and Build the Project again


The bin directory is displayed as above in the project directory. However, the content is changed on the terminal as follows:


In the original classes folder, all class files are generated, such:


Corresponding command:

Run the following command in the project directory:

Generate the. class file:

Javac-encoding GBK-target 1.5-bootclasspath ~ /Android-sdk-linux/platforms/android-18/android. jar-d bin/classes src/com/jltxgcy/helloworld /*. java gen/com/jltxgcy/helloworld/R. java-classpath libs/android-support-v4.jar


4. Right-click Run as Android Application

The bin directory is displayed as above in the project directory. However, the content is changed on the terminal as follows:

AndroidManifest. xml-F bin/resources. ap _

Generate classes. dex:

Dx -- dex -- output = bin/classes. dex bin/classes

Generate helloworld_unsigned.apk:

Apkbuilder bin/HelloWorld_unsigned.apk-v-u-z bin/resources. ap _-f bin/classes. dex-rf src-nf libs

Sign the apk and use the debug key. The alias is androiddebugkey and the password is android:

Jarsigner-verbose-keystore ~ /. Android/debug. keystore-signedjar bin/HelloWorld_signed.apk bin/HelloWorld_unsigned.apk androiddebugkey

Align apk:

Zipalign-v 4 bin/HelloWorld_signed.apk bin/HelloWorld.apk

Remove temporary apk:

Rm bin/HelloWorld_unsigned.apk bin/HelloWorld_signed.apk

Install apk:

Adb install bin/HelloWorld.apk


5. Right-click Android Tools> Export Signed Application Package

In the same step, only the self-created digital certificate (release version) is signed, and the last apk is not saved in the bin directory, but specified by the user.

See http://blog.csdn.net/jltxgcy/article/details/22647101 for details

Related Article

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.