Android App signing

Source: Internet
Author: User

Note: The article was first published in a personal blog, now the technical article transferred to this . http://blog.go3k.org/android-sign/

The Android system requires all programs to be digitally signed to install, and if no digital signatures are available, the system will not be allowed to run the program, whether it is an emulator or a real phone. Therefore, you must set up a digital signature for the application before running the debugger on the device or on the emulator. The Android system will only test the validity period of the signing certificate when it is installed, and if the application's signature expires after installation, the application can still be enabled normally.

Android uses digital signatures to identify the author of an application and to establish a trust relationship between applications, not to determine whether a user can install the application. This signature of Android is done by the application's author and does not require an authoritative digital certificate signing authority, which he only uses to make the application package self-certified.

Default Debug Key signature

When you package a test with Eclipse, ADT automatically uses the debug key to sign the application, and the debug key is a file named Debug.keystore, located on the computer:

/userName/.Android/debug.keystore,其中的userName是电脑的用户名。

The APK package in the project's Bin directory is a package that uses the debug key to make the signature, so it is not theoretically possible to use this package for online publishing.

Generate key Signature

The whole process involves several tools:

    • Keytool generating, modifying operational digital certificates, JDK tools
    • Jarsigner using a digital certificate to sign the APK file, the JDK tool
    • Zipalign the signature apk to improve the efficiency of interacting with Android, the tools in the Android SDK

The simplest way to do this is to use eclipse's capabilities directly:

Right-click the project->android Tools->export signed application package and choose to use an existing KeyStore signature and create a new keystore signature. There are several key messages to remember:

    • Storepass:keystore Password (a keystore can exist under a number of keys, which is the first level of keystore password)
    • Alias: Each key corresponds to an alias name
    • Keypass: master password for single key

Enter the correct KeyStore information to output a packaged APK package.

What if I mistakenly use an app published by Debug.keystore?

That's right... That's what I'm talking about.

Problems that arise

On the first release, copy the APK package directly from the Bin directory and publish the package. This is the use of Debug.keystore signature, and online application, I think this happens because I do not understand the Android application signature-related details.

When found, you want to update your app with a "regular" keystore that you build yourself. Because the KeyStore is replaced, the signature of the installation package is changed. When the user updates the app, an error occurs during the installation process. During installation, the system detects that the signature of the program is inconsistent, that the installation package is risky (may be tampered with), that the installation fails, and that the original application needs to be reinstalled. Such a problem is very serious!!!

Solutions

A word, change!!!

To find the Debug.keystore file, in fact you just need to save this. KeyStore, it is also possible to use the default key for application signing and updating in the future. Just the default password is a bit insecure.

Debug.keystore Default information is:

Alias:androiddebugkey

Storepass&keypass:andriod

Just use Keytool to change Debug.keystore alias, Storepass, Keypass to the value we want.

Modify Alias:

keytool -changealias -alias "your-very-very-long-alias" -destalias "new-alias" -keypass keypass -keystore /path/to/keystore -storepass storepass

Modify Storepass:

keytool -storepasswd -keystore /path/to/keystoreEnter keystore password:  changeitNew keystore password:  new-passwordRe-enter new keystore password:  new-password

Android App signing

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.