Introduction
In this article, you will learn how to create ionic 4 release build for the Android platform.
What is Ionic?
Ionic framework is the free, open-source toolkit for developing high-quality cross-platform apps for native iOS, Android, and the web—all from a single codebase. It allows us to develop UI using the famous frameworks e.g Angular, Vue.js, React, etc.
Setting up release build for Android platform
Steps 1 - Run “npm install” on the root directory
Steps 2 - Add android platform with the CLI:
ionic platform add android
Steps 3 - If you are working in a distributed development environment then make sure to install the required files. Run ionic cordova prepare command. it will Install platforms and plugins listed in “config.xml”.
ionic cordova prepare android
Steps 4 - Now navigate to platforms/android with the CLI :
cd platforms/android
install JDK in system then
- I check "Create new keystore" and realize it does nothing to help me. It still asks for the location of keystore. So I decide to do it the hard way.
- Turned off read-only access on
C:\Program Files\Java\jdk1.6.0_25\bin
and granted theCREATOR OWNER
group full control of the folder. - Open command line on Windows 7 64-bit.
- Traverse to
C:\Program Files\Java\jdk1.6.0_25\bin
. - Run keytool.
C:\Program Files\Java\jdk1.6.0_25\bin>keytool -genkey
-v -keystore d:\Accountbook.keystore -alias Accountbook -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: John Smith
What is the name of your organizational unit?
[Unknown]: Android
What is the name of your organization?
[Unknown]: Company
What is the name of your City or Locality?
[Unknown]: Albany
What is the name of your State or Province?
[Unknown]: NY
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=John Smith, OU=Android, O=Company, L=Albany, ST=NY, C=US correct?
[no]: yes
Generating 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with
a validity of 10,000 days
for: CN=John Smith, OU=Android, O=Company, L=Albany, ST=NY, C=US
Enter key password for <veetle>
(RETURN if same as keystore password):
Re-enter new password:
[Storing company.keystore]
Create/Copy release signing key store file under platforms/android folder Copy the created Key store file for android application if you already have one otherwise generate a key.store file with the CLI and answer all the questions:
keytool -genkey -v -keystore YourApp.keystore -alias YourApp -keyalg RSA -keysize 2048 -validity 10000
Follow the steps suggested in the documentation for Deploying to a Device.
The above command will ask for password and extra info. Keep password and specified info safely as it is required for signing you app.
Step one will create release apk file inside, ./platforms/android/app/build/output/apk/release/app-release-unsigned.apk. Copy app-release-unsigned.apk file to your root project directory where your my-release-key.keystore is located.
Now run the following command (change .keystore and alias_name if required),
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk alias_name
Give required keystore password when asked
Finally run below command to generate final apk
$ANDROID_HOME/build-tools/vno/zipalign -v 4 app-release-unsigned.apk newname.apk
replace newname.apk as per you choice.
for vno. specify android build tools version no. for example.
$ANDROID_HOME/build-tools/28.0.3/zipalign -v 4 app-release-unsigned.apk newname.apk
Now you can upload generated apk into playstore
Create/Specify release signing information
Steps 1 - Create a file with name “release-signing.properties” under “platforms\android” folder.
Steps 2 - Add below information to this file:
key.store=YourApp.keystore
key.store.password=<YourApp keystore password>
key.alias=YourApp
key.alias.password=<YourApp alias password>
Create build for application
Now go back to the root of your Ionic project with the CLI and build a release version:
ionic cordova build android --prod --release
If command run successfully then you will find release APK under – APP_Root_Folder\platforms\android\app\build\outputs\apk\release
Reset plugins and platforms
To install Or reinstall all cordova plugins In Package.json with Ionic, Run this command on windows command prompt with administrator privilege
rd plugins /d/s && rd platforms /d/s && ionic cordova prepare
Conclusion
There are the steps to create a build for ionic 4 application and then you can host your application on the Android store.
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.