Android uses Android Studio + Gradle or command line for APK signature Package

Source: Internet
Author: User

Official Document: Https://developer.android.com/tools/publishing/app-signing.html


1. The default is debug mode, using the signature file in: $HOME/.android/debug.keystore


2. Release Mode Signature:

build.gradle:

Android {signingconfigs {releaseconfig {keyalias ' stone ' keypassword ' mypwd ' storefile file ('/users/stone/documents/ Project_as/myapplication/stone.keystore ') Storepassword ' MyPwd '}}        buildtypes {           release {             ...             Signingconfig signingconfigs.release           }}}        

Signingconfigs is the signature configuration. Configuration name releaseconfig{//config content}

The configuration name for Signingconfigs when you specify release in Buildtypes


Execute Gradle command, $ gradle assemblerelease

Compile and publish. An unsigned apk and an already signed apk can be seen under build/outputs/apk/.

If the signature file is not used, use debug mode's debug signature. That will generate a debug signature apk


3. Signing the password is not secure in Gradle:

Signingconfigs {//gradle assemblereleasemyconfig {storefile file ("Stone.keystore") Storepassword System.console (). ReadLine ("\nkeystore Password:") Keyalias "Stone" Keypassword system.console (). ReadLine ("\nkey Password:")}}

This will require the password to be entered when the command executes the command.


4. Packaging with Android Studio signature

Menu Build > Generate signed APK


5. Automatic signature packaging using Android Studio

A. Open project structure (cmd+;)

B. Select the moudle you want to build, open signing, add Config

When execution is complete, the signingconfigs{config {...} is automatically added to the Build.gradle. of information

C. Open Build Types > Release


Select the defined configuration in the signing config

Zip align enabled defaults to True to enable optimized apk operation

D. $ gradle Build

The compilation type defined in build types is output in the build/outputs/apk/directory

Such as:

myapplication-debug-unaligned.apk
myapplication-debug.apk
myapplication-release-unaligned.apk
myapplication-release-unsigned.apk
myapplication-release.apk


6. Use the Android SDK and the JDK command signature package apk

Create a signature
keytool-genkey-v-keystore stone.keystore-alias stone-keyalg rsa-keysize 2048-validity 10000 generating signature files
Sign the APK
jarsigner-verbose-sigalg sha1withrsa-digestalg sha1-keystore stone.keystore unsigned.apk Stone does not generate new files
Detect if the APK is signed
jarsigner-verbose-certs-verify signed.apk
Optimize APK
Zipalign-f-V 4 signed_unaligned.apk signed_aligned.apk



Android uses Android Studio + Gradle or command line for APK signature Package

Related Article

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.