Ant generates an android project and automatically or manually signs an apk

Source: Internet
Author: User

Let's take a look at the following:

Installation command:
Adb-s emulator-5554install path/to/your/app.apk
The parameters after-s can be viewed through adb devices.
Knowledge is over.

You can use ant to create and compile android projects:
Create a project:
Android createproject-n something-t android-7-p something-k com.
Example. something-aSomething
This creates a something project. The root directory contains build. xml.
When using the project created by eclipse for ant compilation, you need
{Android-sdk-windows} \ tools \ ant \ build. xml
Copy to the project and directory to compile normally. The command is:
Ant debug-the compilation tool has automatically signed the debug key and used zipalign to optimize packaging.
Ant release --- you need to configure the signature and zipalign optimization by yourself. The <project_name> -unsigned.apk file is generated. to automatically sign the file, you also need:
Or add ant. properties under the project root directory:
Key. store = path/to/my. keystore
Key. alias = mykeystore
Or, manually sign and optimize.
 
Manually generate a signature:
Keytool-genkey-v-keystore my-release-key.keystore-alias alias_name-keyalg RSA-keysize 2048-validity 10000
The keytool is in the following folder:
C: \ ProgramFiles \ Java \ jdk1.6.0 _ 22 \ bin
 
It should be:
"C: \ ProgramFiles \ Java \ jdk1.6.0 _ 22 \ bin \ keytool"-genkey-v-keystoremy-release-key.keystore-alias alias_name-keyalg RSA-keysize2048-validity 10000
 
Then you need to sign the file. jarsigner is also in the jdk path:
Jarsigner-verbose-sigalg MD5withRSA-digestalg SHA1-keystoremy-release-key.keystore my_application.apk alias_name
Therefore:
"C: \ ProgramFiles \ Java \ jdk1.6.0 _ 22 \ bin \ jarsigner"-verbose-sigalg MD5withRSA-digestalg SHA1-key store my-release-key.keystore something-release-unsigned.apk alias_name
 
Then we need to use the zipalign tool in androidsdk for optimization, which reduces the RAM consumption when the device runs the application. Because of alignment, we can directly read mmap () instead of copying all data to the memory:
Zipalign-v 4your_project_name-unaligned.apk your_project_name.apk


Author: houshunwei

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.