During the process of creating a project, you often forget about the packaging process of the release and record it.
Before you begin
Learn two things first:
- Keytool is an effective security key and certificate management tool.
- Android requires that all programs must have a signature, otherwise the program will not be installed.
Generate commands
注意
: Remember to alias_name
change it.
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Forgetting to change this name before is a big problem. Here are some questions to ask you:
password:Re-enter new password:What is your first and last name? [Unknown]: phodalWhat is the name of your organizational unit? [Unknown]: phodalWhat is the name of your organization? [Unknown]: phodalWhat is the name of your City or Locality?
注意
: If you want to publish your app to some app market, your signature will be saved, and if the signature is inconsistent, it will indicate a problem ...
Build Android Apps
1. Generate Release Package
Cordova provides a set of device-related APIs that enable mobile apps to access native device features, such as cameras, microphones, and so on, with JavaScript.
--release android
2. Signature
Jarsigner is a tool that is included in the JDK for the signature and validation of jar files.
$jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
注意
: The alias_name should be consistent with the above
3. Optimization
Zipalign is a tool for organizing apk files on an Android platform, and it was first introduced in the SDK Software Development Kit for Android version 1.6. It is able to optimize packaged Android applications to make the interaction between the Android operating system and the application more efficient, which allows applications and the entire system to run faster.
$zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk
注意
: Normally zipalign should be under one of the versions of the SDK in the home directory of your Android SDK under Build-tools.
Turn from 1190000002617037
Ionic Android App release guide