Signature of Android App

Source: Internet
Author: User

Andriod application If you want to install on a phone or simulator, you must have a signature!

The meaning of the signature

In order to guarantee the legal ID of each application developer, it is possible to prevent some open vendors from confusing the installed program by using the same package name.

We need to uniquely sign our release APK file to ensure consistency for each release we publish (such as Automatic Updates will not be installed because of inconsistent versions).

The impact of the signature on your app.

You can not only do an app, you may have a grand strategic project, want to in life, services, games, systems in all areas want to get into the words, you can not only do an app, Google recommends that you put all your apps use the same signing certificate.
With your own signature certificate, no one can overwrite your application, even if the package name is the same, so the impact is:
1) app upgrade . Upgrade software with the same signature can gracefully overwrite the old version of the software, or the system will find that the new version of the signing certificate and the old version of the signing certificate is inconsistent, does not allow the new version to be installed successfully.
2) App modularity . The Android system allows the same app to run in the same process, and if it's running in the same process, they're equivalent to the same app, but you can update them individually, which is an app-level modular mindset.
3) Allow code and data sharing . A signature-based permission tag is available in Android. With the allowed settings, we can implement access and sharing between different apps as follows:

Androidmanifest.xml:<android:protectionlevel= "normal"/>

There are 4 kinds of values for the ProtectionLevel tag:

Normal (default), dangerous, Signature,signatureorsystem.

In simple terms, normal is a low-risk, and all apps cannot access and share the app.
Dangerous is a high-risk, all apps can access and share this app.
Signature refers to apps with the same signature that can access and share the app.
Signatureorsystem refers to the app in the system image and the app with the same signature to access and share the app.
Google recommends not to use this option, because the signature is sufficient, generally this license will be used in an image to share some specific features in the case.

First, why to sign

With so many people developing Android, it's entirely possible that we all put the class name, the package name, in the same name, how do you differentiate it? Signature is a distinguishing function.

Since the developer may be confused by using the same package name to replace the installed program, the signature can guarantee a considerable name, but the signature of different packages is not replaced.

APK If you use a key signature, a file signed by another key when it is published will not install or overwrite the old version, preventing your installed app from being overwritten or replaced by a malicious third party.

This signature is actually a developer's identity. When something happens in a transaction, a signature can prevent it from happening.

Ii. Notes on Signature

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's a simulator 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.

Android signed digital certificates do not require authority to authenticate, is the developer's own production of digital certificates, known as self-signed. Digital certificates are used to identify the author of an application and to establish a trust relationship between applications, rather than to determine which applications the end user can install.

The 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.

You can use the standard tools-keytool and jarsigner-to generate a key to sign the application's. apk file.

Use the Zipalign optimizer after signing.

Simulator development environment, the development of the program through the ADB interface upload will be automatically signed with the debug permission before passing to the emulator. The Eclipse menu is displayed under Windows---Preferences-android–>, our default signing digital certificate for debugging.

When you publish an Android app, you must use a digital certificate generated by a suitable private key to sign the program and not be published using the ADT plugin or the debug certificate generated by the Ant tool.

The above-mentioned Android digital signatures are mostly related to Android apk, and when doing CTS authentication, you need to use the Android system signature.

Why do I need to sign an Android system for CTS certification?

It turns out that the system.img we compiled with MAKE-J4 is using Test key, which is only for the development phase, and the secret key is public and can be used by anyone.

When you publish an Android product, you need to sign the entire system separately to prevent it from being stolen by others. This system is the release version of the Android system.

In an Android system, all applications installed to the system must have a digital certificate that identifies the author of the application and establishes a trust relationship between the applications .

If a permission ProtectionLevel is signature, then only those applications that have the same digital certificate as the program where the permission resides can get that permission.

Android uses a Java digital certificate-related mechanism to give the APK a digital certificate, to understand the digital certificate of Android, you need to first understand the following digital certificate concepts and Java digital certificate mechanism.

The Android system requires that every application installed into the system is signed with a digital certificate, and the private key of the digital certificate is stored in the programmer's hands.

Android uses digital certificates to identify the author of an application and to establish a trust relationship between applications, not to determine which applications the end user can install.

This digital certificate does not require an authoritative digital certificate signing Authority authentication, it is only used to make the application package self-certified.

One: Multiple programs of the same developer use the same digital certificate as much as possible, this can bring the following benefits.

(1) in favor of the program upgrade, when the new version of the program and the old program's digital certificate, the Android system will think that the two programs are different versions of the same program. If the new program and the old version of the digital certificate is not the same, then the Android system think they are different programs, and create a conflict, will require the newly-created program to change the package name.

(2) facilitates the modular design and development of the program. Android allows programs with the same digital signature to run in one process, and the Android program treats them as the same program. So developers can develop their own programs into modules, and users only need to download the appropriate modules when needed.

(3) Data and code can be shared across multiple programs through permissions (permission). Android provides a digital certificate-based permission-granting mechanism that allows applications to share overviews or data with other programs to those that have the same digital credentials as themselves. If the ProtectionLevel of a permission (permission) is signature, this permission can only be granted to programs that have the same digital certificate as the package in which the permission resides.

When signing, you need to consider the numberValidity period of the certificate:

(1) The validity period of the digital certificate should include the program's expected life cycle, once the digital certificate expires, the program that holds the digital certificate will not be upgraded properly.

(2) If multiple programs use the same digital certificate, the validity period of the digital certificate will include the expected lifetime of all programs.

(3) Android market enforces that all application digital certificates remain valid until October 22, 2033.

Two: Android digital certificates contain the following points:

(1)all applications must have a digital certificate, the Android system does not install an application without a digital certificate

(2) The digital certificate used by the Android package can be self-signed and does not require an authoritative digital certificate Authority signature Authentication

(3)If you want to formally publish an android, you must sign the program with a digital certificate generated by a suitable private key , but not with ADTthe debug certificate generated by the plug-in or ant tool to publish.

(4) Digital certificates are valid , and Android only checks the validity of the certificate when the application is installed. If the program is already installed on the system, it does not affect the normal functionality of the program, even if the certificate expires.

(5) Android uses standard Java tools Keytool and Jarsigner to generate digital certificates and to sign application packages.

(6) Use the zipalign optimization program.

Android does not install an APK program that runs without a digital signature, either on the emulator or on the actual physical device.

Android's development tools (ADT plugin and ANT) can help developers sign the APK program, both of which have two modes:

Debug mode and Release mode (release modes).

In debug mode, Android's development tools use a debug digital certificate to sign the program each time they compile, and developers don't need to worry about it.

When you want to publish a program, developers need to use their own digital certificate to sign the APK package, there are two ways to do it.

(1) Use the Keytool in the JDK (for generating digital certificates) and Jarsigner (for signing with digital certificates) on the command line to sign the APK package.

(2) Signing with ADT Export Wizard (if no digital certificate may be required to generate a digital certificate).

Why Android wants to sign all Android applications require a developer to digitally sign a certificate, and the anroid system does not install a program that is not signed. Usually our program can be installed and run on the emulator, because during application development, because the debug interview is compiled, so ADT will automatically use the default key and certificate to sign, and in the release mode, the APK file will not be automatically signed. This requires a manual signature.
Signing the APK can provide the following benefits:
1. Application Upgrade: If you want users to seamlessly upgrade to a new version, you must sign with the same certificate. This is because only the same certificate is signed and the system is allowed to install the upgraded application. If you have a different certificate, your application will be asked to take a different package name, in which case it is equivalent to installing a completely new application. If you want to upgrade the application, the signing certificate must be the same, the package name is the same!
2. Application modularity: The Android system can allow multiple applications signed by the same certificate to run in one process, the system actually uses them as a single application, we can deploy our application in a modular way, and users can upgrade one of the modules independently.
3. Code or data sharing: Android provides a signature-based permission mechanism, so one application can expose its functionality to another application that is signed with the same certificate. By signing multiple applications with the same certificate and leveraging signature-based permission checks, you can share code and data in a secure way between applications. Between different applications, want to share data, or share code, then let them run in the same process, and let them sign with the same certificate.

Signature of Android App

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.