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