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.