Step 1: Customizing Cordova’s config.xml file
Go to your project root and open config.xml file in your text editor.
The first thing to change is your App’s human readable name. Replace the name inside <name></name> to <name>My Quiz App</name>
Second, change the id value inside <widget id=”com.ionicframework.quiz” version=”0.0.1″ xmlns=”http://www.w3.org/ns/widgets” xmlns:cdv=”http://cordova.apache.org/ns/1.0″> to your reverse domain name. For example, id=”com.quiz.app”. This is important. The id is the unique identifier when you publish your app on IOS or Android. In IOS, this will be your bundle ID. In Android, this will be your package name.
Third, if you are updating your app. Please change your version number to a higher value. If this is your first time publishing the app, you do not need to change that.
If you want your app only in portrait mode, you can add this line in the xml file as well: <preference name=”orientation” value=”portrait” />
For more customization information, please visit Cordova Official Site
Step 2: Building and Signing your Android Release
We will need to build a digitally signed Android release APK file to distribute your app on Google Play Store or other app distribution channels. (Your will need to pre-install Android SDK before moving to this step)
- Add Android platform support in your app if you have not done so. Inside your app root folder, type in terminal: $ ionic cordova platform add android
- Create your digital signed key $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000Follow the on screen instruction to type in your password and information. Please save this key in a safe location. You will need it again when you sign a new build and release an update.
- Build an release version of your app $ ionic cordova build –release androidIt will generate an android-release-unsigned.apk file under your platform/android/build/output/apk path. Copy the apk file into your app root folder so you do not need to type in the path.
- Sign your release build apk. $ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore android-release-unsigned.apk alias_name
- Align your build with zipalign tool for android build tool. $ [Your Android SDK path]/build-tools/[Newest version number]/zipalign -v 4 android-release-unsigned.apk myapp-signed.apkIf you keep getting command not found error, You can also just navigate to your android sdk folder, find the zipalign tool under build-tools, version number and drag the folder into your terminal to get the absolute path.
The myapp-signed.apk is the final signed apk file you need to upload onto Google Play Store or any other Android distribution networks.
Publish your app on Google Play Store. Now that we have our release APK ready for the Google Play Store, we can create a Play Store listing and upload our APK. To start, you’ll need to visit the Google Play Store Developer Console and create a new developer account. It will cost $30 one time fee.
Once you have a developer account, you can go ahead and click “Publish an Android App on Google Play” and follow the on-screen instruction.