Cordova PhoneGap CLI Android complete tutorial

Cordova/PhoneGap is a great tool to create native mobile apps using Html/Css/Javascript.

Softwares you need.

Node.js
Java JDK (After installing it, run SDK Manager and get updates)
Android SDK
Git Commond line tool (Optional)

Make sure following Path variables are setup:

(New User Variable)JAVA_HOME -> C:\Program Files\Java\jdk1.8.0_45

User PATH:
C:\Program Files (x86)\Java\jre1.8.0_45\bin;
C:\Users\eliza\AppData\Roaming\npm;
C:\Program Files (x86)\Android\android-sdk\tools;
C:\Program Files\Java\jdk1.8.0_45\bin;
C:\Program Files (x86)\Android\android-sdk\build-tools\21.1.2 <- is available only after you run SDK manager & update


System PATH : 

C:\Program Files\nodejs;zipalign;
C:\Program Files (x86)\Git\cmd;
C:\Program Files (x86)\Git\bin

Cordova Official site has all you need to setup a project.

Here are steps:

install Node.js

Run CMD as Admin

npm install -g cordova
Create a folder and navigate to it, Then
cordova create hello com.example.hello HelloWorld
cordova platform add android
cordova build android
Find apk here > C:\Cordova\YouTubeVideo\platforms\android\build\outputs\apk

do all of your work within WWW directory, just make sure following file is referenced within your index.html file:

<script type="text/javascript" src="cordova.js"></script>

Self Sign the APK for play store. 

run following commands within the APK directory

You can change .keystore name & alias name)
keytool -genkey -v -keystore dzone.keystore -alias dzone -keyalg RSA -keysize 2048 -validity 10000

(skip above if key is created already using keytook. change to api folder)
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore dzone.keystore android-release-unsigned.apk dzone

zipalign -v 4 android-release-unsigned.apk DesiTv-release.apk

now DesiTv-release.apk is good to go for Android Play Store.

Below are videos for reference


Build Apk


Self Sign

Posted by:

Comments History


by: on
and to test it on device, here is a easy way....

Connect Device to Computer
Make sure USB drivers are installed for windows
Settings > About Phone > Build Number (Tap multiple Times)
When Developer Mode is enabled then turn on "USB Debugging"

Now go to CMD and do...
(under platforms-tools folder)
adb-kill-server  
adb-start-server
adb devices
(copy the device ID, if it is showing unauthorized then, unplug and plug in the device again or try to turn on/off the usb debugging again)

now within cordova run this...

cordova run android --47DXXX2B (replace with your device id)

Thats all.

 
by: on
I believe now you need to sign APK using new version of SSL, or else your APK will get rejected....here is the tutorial:

http://codinglogbook.com/mobile-app-development/how-to-sign-and-secure-your-apk-for-google-play/


 

Name :  

Email :  

Comment Below