9

I have created simple apps in local directory, that app name is Ionic-Chat-master

How can i make this to apk file?

i have tried the following command using git but not worked for me

npm install -g cordova

cordova build --release android

This displays an error (sh.exe": cordova: command not found).

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Vijaya Kumar
  • 137
  • 1
  • 2
  • 7

7 Answers7

28

If you want generate .apk using Ionic FrameWork . thats very simple for the sake of this discussion I created the sample app and convert that sample app in to .apk using Ionic Command.

1.Create a Ionic Sample App,

$ionic start Ionic-Chat-master

2.Adding a platform to that project

for ios

C:\Ionic-Chat-master>ionic platform add ios

and for android

C:\Ionic-Chat-master>ionic platform add android

3.Previewing on a mobile device(Be Sure your device is Connected)

for ios

C:\Ionic-Chat-master>ionic run ios -l –c

for android

C:\Ionic-Chat-master>ionic run android -l –c

4.Deploy to an android device

C:\Ionic-Chat-master>ionic build android

These are the Commands which leads to achieve a .apk .

SakthiSureshAnand
  • 1,324
  • 16
  • 32
  • Perfect Answer.. That saves my day . – Beckham_Vinoth Aug 21 '16 at 06:45
  • 6
    and then get apk from ~yourIonicProjectFolder\platforms\android\build\outputs\apk – Deepak Thakur Mar 09 '17 at 13:52
  • 4
    Latest Ionic CLI run commands requires additional syntax, each command should be "ionic cordova" instead of "ionic". Works the same as above. – Andrew Stalker Jul 27 '17 at 08:47
  • Keep in mind that once you have built an apk, you won't be able to just put it online somewhere and install it on your phone by visiting the link, you will then have to have `developer options` (Settings > About > tab `Build number` 5 times on phone) enabled to allow `unknown sources`, then you will also have to `sign the APK` and `zipalign it` - basically adding a identity and password to it, which is utilised for marketplace updates, this will then allow it to be installed on your phone. Instructions can be found here: http://ionicframework.com/docs/v1/guide/publishing.html – Grant Aug 13 '17 at 09:06
7

First of all you have to install

  1. node.js
  2. apache ANT
  3. Java JDK & JRE
  4. Android SDk & Eclipse

and then after all installation you have to set this all software path into environmental- variable. and then fire your npm install -g cordova. without this all software installation and there path setup your phoneGap application will not created. and still you have any confusion and any question related software installation and there path setup then again tell me i will help you.

Tim
  • 41,901
  • 18
  • 127
  • 145
5

The easiest way, no need to install anything:

ionic package build android

(magic happens in the cloud)

Then you can download .apk to a computer or your Android device.

Mars Robertson
  • 12,673
  • 11
  • 68
  • 89
2

First create an account at Ionic Io ,

then in your project directory hit this - >

ionic io init

then log in there and hit this

ionic package build android

no need to install anything...

Partha Roy
  • 1,575
  • 15
  • 16
0
ionic platform add android
ionic build --release android
ER.SHASHI TIWARI
  • 917
  • 1
  • 10
  • 25
0

We need to execute below mentioned steps to generate .apk with gradle build system:

Through out the steps I have assume that I am creating 'MyApp' project

Step 1 : generate myapp.keystore file using below mentioned command :

keytool -genkey -v -keystore myapp.keystore -alias myapp -keyalg RSA -keysize 2048 -validity 10000

Step 2 : create ant.properties file with following details :

storeFile=myapp.keystore
storePassword=<<your keystore password>>
keyAlias=myapp
keyPassword=<<your keystore password>>

Step 3 : create gradle.properties file with the path to set ant.properties file :

cdvReleaseSigningPropertiesFile= <<path to ant.properties>>

Step 4 : Use last command as mentioned below :

ionic build android --release

Note : You must have set path for : java, adb, jarsigner, zipalign

Your generated apk will be in build folder.

Nirav Shah
  • 2,064
  • 5
  • 24
  • 34
0

for ionic 3 add ionic login enter email and pwd then

ionic package build android

please login and check the apk file.

Ankur Soni
  • 746
  • 6
  • 17