Installing & starting with PhoneGap on Windows for cross platform mobile development

Build-BotPhoneGap is a great framework for creating cross platform apps (Android, iOS, BB, WM, etc.) using HTML, CSS, and JavaScript and uses Apache Cordova™. Installing and testing on Windows takes little setup, below I’ve tried to cover all of the steps needed to get going. My setup / guide below uses Windows 7, 64 bit, it seems like many steps, but in reality is pretty easy.

  1. Install node.js from nodejs.org (use default settings).
  2. Open a command prompt (cmd) and run:
    1. npm install -g phonegap
    2. npm install -g ant
    3. npm install –g cordova
    4. Now add ‘C:\Users\<yourusername>\AppData\Roaming\npm\node_modules\ant\ant\bin’ to the Path system variable
    5. Download and extract the Android SDK from https://developer.android.com/sdk/index.html
      1. I extracted to c:\mobile\androidsdk (referenced below as <yoursdkpath>)
      2. Add <yoursdkpath> + \sdk\platform-tools to the Path system variable
      3. Add <yoursdkpath> + \sdk\tools to the Path system variable
      4. Now to setup an Android image to emulate and test with:
        1. In the sdk folder, run Eclipse (ie: C:\mobile\androidsdk\eclipse\eclipse.exe
        2. Create or use the default workspace
        3. In Eclipse, under Window choose Android SDK Manager
        4. In the SDK Manager, make sure these are checked:
        5. i.      Tools > SDK Tools, Platform-tools
        6. ii.      Android <you choose the version> SDK Platform, Arm system image & Intel system image (if available)
        7. iii.      Extras > Android Support Library, Google USB Driver, Intel x86 emulator HAXM
  3. Click Install x Packages, accept all licenses
  4. When downloads are finished, close the SDK Manager
  5. If you want to speed up the Android emulator, I suggest installing the Intel HAXM located at: \sdk\extras\intel\Hardware_Accelerated_Execution_Manager
  6. Now back in Eclipse (restart if you’ve installed the HAXM), you can go to Window > Android Virtual Device Manager.
  7. Click “New” to create a new virtual device
  8. Choose a name (anything you want)
  9. Choose a device (something simple like the “4.0” WVGA”)
  10. Choose a target (this is what you downloaded in step 4d).
  11. In CPU, choose Intel if it’s available (it’s not required, but if it’s not available, double check the HAXM install and the download the Intel system image for your target version)
  12. Now you can click “OK”
  13. In the list of virtual devices, choose your new device and click “Start”
  14. Provided you don’t see any errors, after a few minutes (be patient) you’ll have a working Android emulator going. android-emulator
  15. Now, let’s do a quick project and test it! Go back to cmd (your command prompt).
  16. Create your project with, run: cordova create hello com.ex.hello “HelloChris”
  17. Go to the project directory, run: cd hello
  18. Add android to the project, run: cordova platform add android
  19. To make sure your project is ok, run: cordova build
  20. Now if you don’t already have your emulator running, go back into Eclipse into the Android Virtual Device Manager and start your device.
  21. When it’s running, run: cordova emulate android
  22. That’s it; you should see “your” app on the emulator in a few seconds. (It reads “device ready” with a logo or something…).

To get started creating your own app, browse to the folder (ie: \mobile\hello\www) and start editing and creating files. Enjoy!

android-emulator2

Installing & starting with PhoneGap on Windows for cross platform mobile development

29 thoughts on “Installing & starting with PhoneGap on Windows for cross platform mobile development

  1. Joe says:

    Also on Window 8.0 it seems that %SystemRoot%\System32 is not configured in the path by default. Consequently “cordova platform add” will throw an exception, having no known path to xcopy

    And what am I doing developing on a Win8 machine? That’s a sad, sad story …

    Like

  2. Rajiv gupta says:

    sir while running command “npm install -g phonegap” on cmd, i am getting soo many errors like npm error not ok code.
    please help me sir in installing phonegap.

    Like

  3. Hi Chris. Hope you are doing great. How do I open apps(calendar) on windows phone 8 with Cordova/PhoneGap. My development has come into a situation where my app needs to interact with other apps on Windows Phone 8.

    Say when users click a button(in the Cordova which means it’s a html element) a windows phone 8 app will be opened(let’s say calendar).

    I have searched many hours and only found calendar plugins for android and ios, there is really no one for WP platform?

    Like

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