create build and run hello world application in cordova Category : Cordova Tutorials | Updated at : 2019-01-31 01:10:16

Create Your PhoneGap / Apache Cordova Project

Run this Command in your command prompt

cordova create FolderName com.companyname.appname AppName

Where,

FolderName: Your Folder name for your New Project

com.companyname.appname: Unique identifier for your application.

AppName: is your application name (without Space)

Example :

cordova create FirstProject com.phonegappro.hello HelloWorld

 

--------------------------------------------

See all platform list suppported by cordova

 cordova platform list

--------------------------------------------

Add browser platform

cordova platform add browser

--------------------------------------------

Run app in browser platform

cordova run browser

cordova run browser -- --port=8001 

--------------------------------------------

Add Android or Platform.

You can add android, iOS, Windows or other platforms to your phonegap projects
 

cordova platform add android

cordova platform add android@x.x.x

cordova platform add ios

Add your plugin if required,

You can add required plugins for your Cordova projects, such as device, device-motion, Geolocation and more. Refer our cheatsheet for Cordova commands http://phonegappro.com/tutorials/phonegap-cheatsheet-part-2/
 

cordova plugin add org.apache.cordova.device

cordova plugin add cordova-plugin-device

When you execute this command, plugins will be download & installed automatically as per your platform

Building your first PhoneGap Project

For Getting the .apk / output file you’ve to build your PhoneGap projects

cordova build android

Emulate Your Project

Run emulate command for running your project on the emulator. for emulating your project you need to create an emulator from your AVD.

cordova emulate android

//SET Target

<preference name="android-targetSdkVersion" value="26" />

//Plugins

 

SPLASHSCREEN

cordova plugin add cordova-plugin-splashscreen

<preference name="ShowSplashScreenSpinner" value="true" />

<preference name="SplashScreenDelay" value="1500" />

STATUS BAR

cordova plugin add cordova-plugin-statusbar

StatusBar.backgroundColorByHexString("#C0C0C0"); 

App Release

--------------

If you do cordova build --release the inspect will be disabled

Update: Since Cordova 5.0.0 the build system uses gradle. See this thread for more info: Specify signing config for Gradle and Cordova 5

-------

cordova build android --prod --release

cordova build --release android

We get

Example-release-unsigned.apk

-----------

Keystore Generation

Syntax:

keytool -genkey -v -keystore <keystoreName>.keystore -alias <Keystore AliasName> -keyalg <Key algorithm> -keysize <Key size> -validity <Key Validity in Days>

Bug Fix - Pair

keytool -genkeypair -v -keystore <keystoreName>.keystore -alias <Keystore AliasName> -keyalg <Key algorithm> -keysize <Key size> -validity <Key Validity in Days>

Eg:

keytool -genkeypair -v -keystore my-release-key.keystore -alias coffdroid -keyalg RSA -keysize 2048 -validity 10000

----------------

JARSIGN

-------------

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore android-release-unsigned.apk <Keystore AliasName>

---

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore android-release-unsigned.apk appname

 

PROBLEM FACED

-------------------------

  1. Forgot <Keystore AliasName>

keytool -keystore <keystoreName>.keystore -list -v

keytool -keystore formconnect.keystore -list -v

----------------------------------

Zipalign

----

Zipalign located in sdk/build-tools/21.1.2

zipalign -v 4 Example-release-unsigned.apk Example.apk

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

/home/kavin/android-sdk-linux/build-tools/23.0.1/zipalign -v 4 android-release-unsigned.apk android.apk

----











 

EVERY APP NEEDED EXTENSIONS:

---------------------------------------------------

 

cordova-plugin-statusbar  

to change to change status bar color

cordova-plugin-x-toast 
Cordova-plugin-admob-free 

Admob advertisements