Android App signing method

Source: Internet
Author: User

1. Why do I need to sign the Android app? If you can only answer this question in a simple sentence, I will say, "This is what the Android system requires." Android requires every Android app to be digitally signed to install into the system, meaning that if an Android app is not digitally signed, there is no way to install it! Android uses digital signatures to identify the author of an application and establish a trust relationship between applications, not to determine which applications the end user can install. This digital signature is done by the author of the application and does not require an authoritative digital certificate signing Authority authentication, which is only used to make the application package self-certified. 2. Why do I develop an Android application that does not have any signatures to run on the emulator and the phone? you do not have to sign the Android app and it doesn't mean that the Android app is not signed. To facilitate our development of the debug program, ADT automatically uses the debug key to sign the application. Debug key? Where is it? The Debug key is a file named Debug.keystore and its location: system drive letter :/documents and settings/Jiangdongguo/.android/debug.keystore"Jiangdongguo" corresponds to your own Windows operating system user name, what, is not already found it. This means that if we want to have our own signature, instead of having ADT sign it for us, we also have a key file (*.keystore) that belongs to you.

3.Android Application Signing steps

apk signature work can be done in two ways: 1) Complete the APK signature via the graphical interface provided by ADT; 2) Full DOS command to complete the APK signature

method One : Complete the APK with the graphical interface provided by ADT

1) Select the appropriate project right-click Properties->android tools->export signed Appliction package

2) Create a certificate for your app



Finally, we can sign the application in E:\Android\SPQ\bin\SPQ_signed.apk. Method Two : The following will explain how to complete the APK signature by commandA total of 3 tools are used to sign the APK, or 3 commands, namely: Keytool, Jarsigner and zipalign, and the following is a brief description of the 3 tools: 1) Keytool: Generate a digital certificate, that is, the key, that is, the type of file with the extension. KeyStore mentioned above; 2) Jarsigner: Use digital certificate to sign APK file;3) Zipalign: Optimize the signature apk to improve the efficiency of interacting with Android (Android SDK1.6 version starts with this tool)The effects of these 3 tools can also be seen in the order in which these 3 tools are used. Usually all of the applications we develop ourselves use the same signature, that is, using the same digital certificate, which means: If you are signing the Android app for the first time, the 3 tools above will be used, but if you already have a digital certificate and then you sign the other apk later, You just need to use Jarsigner and zipalign to do it. To facilitate the use of the above 3 commands, you first need to add the paths of the above 3 tools to the environment variable path (I said it is for ease of use, did not say that this must be done). How to configure the environment variable is not explained here, here you need to say the default path of the 3 tools: 1) Keytool: The tool is located in the bin directory of the JDK installation path; 2) Jarsigner: The tool is located in the bin directory of the JDK installation path;don't know if you notice that Keytool and jarsigner two tools are JDK-generated, which means that digital certificates and file signatures are not patented by Android In addition to the literal understanding of Jarsigner can also be guessed that the tool is primarily used to sign the jar file. 1) Generate an unsigned apk filenow that we have to sign the apk ourselves, we no longer need the ADT to sign it for us by default. How do I get an unsigned apk file? open Eclipse, right-click on the Android project name, select "Android Tools"-"Export Unsigned application Package ..." and select a storage location to save. This will get an unsigned apk file. 2) Generate a digital certificate using the Keytool tool Pcisuntekkeytool-genkey-v -keystore pcisuntek.keystore-alias pcisuntek.keystore -keyalg rsa-validity 20000Description:1) Keytool is the tool name,-genkey means to generate a digital certificate operation, and-V to print out the details of the generated certificate, displayed in the DOS window;2)-keystore pcisuntek. KeyStore indicates the file name of the generated digital certificate is "Pcisuntek. KeyStore";3)-alias pcisuntek. KeyStore indicates that the certificate has an alias of "Pcisuntek. KeyStore" and can of course not be the same as the file name above;4)-keyalg RSA indicates that the algorithm used to generate the key file is RSA;5)-validity 20000 indicates that the digital certificate is valid for 20,000 days, meaning that the certificate will expire after 20,000 dayswhen you execute the above command to generate a digital certificate file, you are prompted to enter some information, including the certificate's password, as shown in the following example:       Note: The execution of the command succeeds and the system generates a "Pcisuntek.keystore" certificate in the current directory (C:\Users\jiangdongguo). 3) sign the Android app with the Jarsigner tooljarsigner-verbose -keystore pcisuntek.keystore -signedjar spq_signed.apk spq.apk pcisunte K.keystore Description:1) Jarsigner is the tool name,-verbose indicates the details of the signature process is printed out, displayed in the DOS window;2)-keystore pcisuntek. KeyStore indicates the location of the digital certificate used by the signature, there is no write path, which is indicated in the current directory ;3)-signedjar notepad_signed.apk notepad.apk to notepad.apk file signature, signed file name is spq_signed.apk;4) The last Pcisuntek.keystore represents the alias of the certificate, which corresponds to the name after the-alias parameter when generating the digital certificate         Note: If your previous program is a default signature (i.e. debug signature), once the new signature application will not overwrite the installation, the original program must be uninstalled before it can be installed. Because the program covers the installation main check two points:1) The entry activity for the two programs is the same. Two programs if the package name is not the same, even if all the other code is exactly the same, it will not be considered a different version of the same program;2) Whether the signatures used by the two programs are the same. If the signatures of the two programs are different, even if the package name is the same, it will not be treated as a different version of the same program and cannot overwrite the installation. In addition, someone may think that the debug signature application can be installed anyway, there is no need to sign their own. Don't think so, debug signed applications have such two limitations, or risk:1) The debug signature app cannot be sold on Android Market, it will force you to use your own signature;2) Debug.keystore on different machines may not be the same, it means that if you change the machine for the APK version upgrade, then the above program will not cover the installation of the problem. Do not belittle this problem, if you develop the program only you use, of course, no matter, uninstall and install it. But if your software has a lot of customer use, this is a big problem, the equivalent of software does not have upgrade features!

Android App signing method

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.