How to generate android apk without Android Studio using IONIC

Hi Folks, Today I’m going to show you how to build and generate android apk file using ionic. I assume that we are familiar with Ionic app development. Ionic is Hybrid Mobile App Development framework using HTML, CSS, Javascript. It uses angularJS 1 and 2. When we develop mobile app on hybrid platform we need to compile it to native platform then only we will get apk files. In order to do that we need multiple dependencies to generate apk file. Thanks to ionic framework for providing such a simple way to generate apk file. Ionic framework provides cloud based service to build apk files.

Ionic cloud will take care of configuration, compilation and packing. just one command gives you apk files. I hope you understand the concept of what I’m going to show you. lets dive into it.

I assume that you have already one working or sample ionic app project to do our work. First we need ionic account for us to build apps. if you don’t have one create your ionic account. For our purpose I’m going to install ionic basic tabs app and try to build it. To do that we need to install it using the following command

ionic start CoolApp tabs

After this cd to CoolApp and run below command

ionic serve

If everything is OK it will start browser and you can see our CoolApp in browser.To create apk file this much simple app is enough. Now press Ctrl+C to kill the ionic app. Run the below command to login with your ionic username and password.

ionic login

It will ask for Email and password after entering correct details it will give you Logged in! message. Now you are ready to create apk and publish your app. To do that we need to run one command

ionic package build android

Oh yes!, you got an error right? yes you will see this error message

Error: Missing Ionic App ID. Make sure to run “ionic upload” first or set your app_id in the ionic.config.json file.

This is because we have to create app in ionic dashboard. Go to https://apps.ionic.io/apps/ . In Dashboard click on New App button. There you have to provide app name. After creating it will navigate to app dashboard page there left corner app name with app id ex: ID: 0ab41f9a

Copy that Id and paste it into your ionic.config.json file. File content looks like

{
"name": "myApp",
"app_id": " 0ab41f9a",
"v2": true,
"typescript": true
}

Now run that command again. After completion of that command you can go to your ionic app dashboard and select package tab. there you can see your app apk file. That’s It. Your are ready to install it on any android device and test it.