Android uses Keytool and Jarsigner to implement signature

Source: Internet
Author: User

1, generate the official version, and find the path to the unsigned file, write down


demo-unsigned.apk

2. Generate signature KeyStore file with Keytool

Keytool-genkey-v-keystore <keystorename>.keystore-alias <keystore aliasname>-keyalg <Key algorithm& Gt -keysize <key size>-validity <key validity in days>

<keystorename>: The signature file name to be generated, the extension is KeyStore
<keystore Aliasname>: The alias of a signature, as the sole basis of
<key Algorithm>: Encryption method, such as RSA
<key Size>: Signature length, can be ignored
<key validity in Days>: Valid, Unit is day

After you enter the above command, follow the prompts, respectively:
Enter the password,
Confirm Password,
Organizational unit name,
Organization Name,
City
Province
Country two letter code (China is CN)

Finally, check the above information, press Y to complete

Enter the main password, here I do not know why to divide two, direct return means to use the same password.

3, using Jarsigner to sign unsigned applications and generate signed applications


Jarsigner-verbose-keystore <keystorename>-signedjar <output signed APK file>-digestalg sha1-sigalg MD5wit HRSA <unsigned APK file> <keystore Alias name>

<keystorename>: The signature file (with extension KeyStore) generated by Keytool in the previous step
<output signed APK file>: File output after signing
<unsigned APK file>: Unsigned and now used to sign the file
<keystore alias Name>: Alias with signature (without extension Keystore)

Then, press the prompt to enter the password set in the previous step, you can do it.


about Keytool and Jarsigner display garbled problem, solution

Part of the script in MAC OS X terminal output is not normal Chinese, instead of, that is garbled, because its encoding is not correct. This thought UTF-8 can conquer the conquering, who knows that some people do not follow the common sense card, such as Keytool and Jarsigner ...

Workaround:
After opening the terminal in the menu-preferences-description file-Advanced, the following text encoding settings, the default is UTF-8, here I change to Chinese (GB 18030), at least Keytool and Jarsigner returned Chinese can be displayed normally.

Attention:
Different color styles have their own set of advanced options, so changing the text encoding and switching the other color styles does not bring the settings to pass.

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.