Android Studio uses formal signatures for debugging

Source: Internet
Author: User

In Android Studio, you can use Gradle to sign yourself when you package.

In fact, Android Studio will add debug signatures to debugging apps by default, but sometimes when third-party SDKs are tuned. A formal signature is required for the ability to adjust. So let's share the method of using Gradle's own active signature.

First, create a signature file

Open as, select Build->generate signed APK, select the item you want to package, and click Next. Then click Create New ... Create a signature file


Fill in the signature file response information. For example, see below. Password, Key-alias, Key-password These three values need to remember, and then click OK, complete the creation.


After completion, a JKS signature file is generated on the corresponding path. If you choose to manually and then package, you will be able to select the signature file, and then fill in the corresponding password and aliases, signed, also can.


Second, the configuration gradle their own initiative packaging

Copy the signature file to the main project root folder, open the Build.gradle file for master project, and under the Android node, add the following:

Signingconfigs {        Release {            storefile file (' Keystore.jks ')            storepassword ' 123456 ' keyalias ' yyh '            Keypassword ' 123456 '        }    }    Buildtypes {        Release {            minifyenabled false            proguardfiles getdefaultproguardfile (' Proguard-android.txt '), ' proguard-rules.txt '            signingconfig signingconfigs.release        }        Debug {            signingconfig Signingconfigs.release        }    }
StoreFile file: Signature files, if placed in other paths, need to be changed accordingly

Storepassword:password (the first password just completed)

Keyalias: Aliases

Keypassword: alias Password

Then build the project again, expand the right-hand column Gradle tab, as seen in the following:


Assemblerelease, which is formally signed.

Double-clicking assemblereleasewill start running the command:

run finish to see the build successful, stating that the formal signature package was successful. Expand the build directory for project. APP-RELEASE.APK can be found, which is the official version number.


The next time you run directly. It's officially signed. This is easier than manual signature.

Of course, to improve security, we can also configure those four properties as variables in the gradle.propreties of the main project, and then reference the variable in Build.gradle.

For example, the following:



This can also play the same effect.

Third, the meaning of application signature
(1) Protect the legal rights and interests of developers
After we have packaged the signature with the program, it means that the application was developed by the signer or agency and has full rights to the application.


(2) Prevention of application substitution
Application signing can prevent some malicious tampering by using the same package name to confuse the replacement of an already installed program.

The APK assumes that a key signature is used and that a file signed with a key when it is advertised will not install or overwrite the old version number. This will prevent your installed apps from being overwritten or replaced by malicious third parties.

is actually an identity.
(3) Ensure consistency of application version number
The general application will have an update, that is, the version number of the upgrade. It is assumed that the application's signature is inconsistent and cannot be replaced by an update. So the signature of the application is the prerequisite to ensure that the current application is properly updated and installed.


(4) Ability to share data and code among multiple programs through permissions (permission)

Android provides a mechanism for assigning permissions based on digital certificates. Applications can share overviews or data with other programs to those that have the same digital credentials as themselves. Assuming that 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.

There is one more aspect. Android system agrees to have the same digitally signed program executed in one process, the Android program will treat them as the same program. So developers can develop their own programs into modules. Users simply need to download the appropriate modules when they need them.



Android Studio uses formal signatures for debugging

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.