Cordova (aka PhoneGap) Installation ERROR & Solution

Installation requirements :

  1. Ant (download from ant.apache.org )
  2. Java JDK (download from www.oracle.com)
  3. Android SDK (download from www.Android.com)
  4. Nodejs (download from NodeJS.org)

 

Install

Step 1 :

To Install 3.3: Ensure that you have NodeJS installed, then open your command line (CMD in windows) and run the following:

        
    		c:\> npm install -g cordova
        

Step 2 :

Navigate to a directory where you store projects on your system. For example:

        
            c:\>cd Projects
            c:\>Projects\ cordova create myApp com.myApp.main myApp
        

Step 3 :

Navigate to the project directory:

        c:\>projects\cd myApp

Step 4 :

Add the platforms you want to support. For example, to add support for Android, type

        
           c:\>projects\myApp\ cordova platforms add android
        

Note* :Most users have issues and seen error message like below (if you are not seeing this error message and android platform installed successfully then this is not for you, jump to 5. below)
        
            C:\project\myapp>cordova platforms add android Creating android project… Error: An error occured during creation of android sub-project.
            C:\Users\Sname\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
            throw e; ^ Error: ERROR : executing command ‘ant’, make sure you have ant installed and add ed to your path. at C:\Users\Sname\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.j s:47:27 at ChildProcess.exithandler (child_process.js:641:7) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:743:16) at Socket. (child_process.js:956:11) at Socket.EventEmitter.emit (events.js:95:17) at Pipe.close (net.js:466:12)
            at C:\Users\smohatad\AppData\Roaming\npm\node_modules\cordova\src\platform.j s:282:30 at ChildProcess.exithandler (child_process.js:641:7) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:743:16) at Socket. (child_process.js:956:11) at Socket.EventEmitter.emit (events.js:95:17) at Pipe.close (net.js:466:12)
        

Fix

Open CMD prompt and do following

        
        c:\> set ANT_HOME = c:\ant 
        c:\> set PATH=%PATH%;%ANT_HOME%\bin 
        c:\> set JAVA_HOME = c:\jdk1.6.0_27 
        c:\>set PATH=%PATH%;;C:\AndroidDevelopment\adt-bundle-windows-x86_64-20131030\sdk\platform-tools;C:\AndroidDevelopment\adt-bundle-windows-x86_64-20131030\sdk\tools        
        

Once all these steps completed. Now run below command

        
        cordova platforms add android
        

Step 5 :

If you want to add plugins to myApp, make sure you are in the “myApp” directory, and add basic plugins to your projects, for example:

        
	C:\project\myApp> cordova plugin add org.apache.cordova.device
        

Step 6 :

That’s it; you are good to go……
I will be adding more to this article once in near future.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s