Onic Android Signature Package configuration Android SDK tools configuration
The so-called Anrdoid package is to package the Ionic project into an apk file that can be installed on an Android system, when packaged, using the Cordova tool, but before you do, you need some preparation: Configuring the JDK, Android The SDK also has each Android version of the package download, the most important is the need to successfully create a ionic project, for the Ionic project to create a detailed tutorial, please refer to the following articles:
IONIC3 Start
Configuring the JDK
The main process is the following: Download configure environment Variables test
JDK Download
Configure environment variables: Add Jdk_home to Path
Test under command line
Java
Javac
Configuring the Android SDK
http://www.androiddevtools.cn/
Android SDK environment variable configuration
Command:
Android SDK test environment variable is configured successfully
Android-h View information
Android Studio AVD default location environment variable
Android Studio Install node installation
Address: https://nodejs.org/zh-cn/
Proxy settings:
NPM Set registryhttps://registry.npm.taobao.org # Register module image
NPM set Disturl https://npm.taobao.org/dist# node-gyp compile-dependent node source image
# # Select the following to add
NPM set Chromedriver_cdnurl http://cdn.npm.taobao.org/dist/chromedriver# chromedriver binary package image
NPM set Operadriver_cdnurlhttp://cdn.npm.taobao.org/dist/operadriver # operadriver binary package image
NPM set PHANTOMJS_CDNURLHTTP://CDN.NPM.TAOBAO.ORG/DIST/PHANTOMJS # PHANTOMJS binary package image
NPM set Sass_binary_site http://cdn.npm.taobao.org/dist/node-sass# node-sass binary package image
NPM set electron_mirrorhttp://cdn.npm.taobao.org/dist/electron/# Electron binary package image
NPM Cache Clean # empty caching
Ionic Installation
Using the node and NPM settings, let's install the ionic and Cordova CLI.
$ npm install-g Ionic Cordova
Note: this-G means that this is a global installation, so you need to open the Administrator command Prompt for window. For Mac/linux, you need to run sudo with a command.
When you are done, create your first Ionic application:
$ Ionic Start HelloWorld blank
To run your application, please CD into the created directory and run the Ionic serve command to test your application in the browser!
$ CD HelloWorld
$ ionic Serve
Ionic packaged Android SDK
Production Build
To run or build your app for production, run
Ionic Cordova run Android--prod--release
# or
Ionic Cordova Build Android--prod--release
This narrows your application's code to ionic's source code and removes any debugging functionality from the APK. This feature is typically used when deploying applications to the Google Play store.
Sign Android APK
If you want to publish your app in the Google Play store, you must sign the APK file. To do this, you must create a new certificate/KeyStore.
Let's use the Keytool command that came with the JDK to generate your private key:
Keytool-genkey-v-keystoremy-release-key.jks-keyalg rsa-keysize 2048-validity 10000-alias My-alias
You will first be prompted to create a password for the keystore. Then, to answer other good tool questions, when all the work is done, you should create a file named My-release-key.jks in the current directory.
Note: Make sure to keep this file in a safe place, and if you lose it, you will not be able to submit the update to your application!
To sign an unsigned apk, run the Jarsigner tool, also included in the JDK:
Jarsigner-verbose-sigalg Sha1withrsa-digestalg Sha1-keystore My-release-key.jks Android-release-unsigned.apkmy-alias
This is the appropriate location for the APK. Finally, we need to run the zip alignment tool to optimize the APK. The Zipalign tool can be found in the/path/to/android/sdk/build-tools/version/zipalign. For example, on OS X with Android Studio installed, Zipalign is located in ~/library/android/sdk/build-tools/version/zipalign:
Zipalign-v 4 android-release-unsigned.apkhelloworld.apk
Verify that your apk is signed to run Apksigner. Apksigner can also be found in the same path as the Zipalign tool:
Apksigner Verify helloworld.apk
Now that we have our final version of binary file helloworld.apk, we can post this binary file on the Google Play store for the world to enjoy!
Ionic Android Signature Package configuration