Updating Apache Cordova to the latest version only takes a few minutes. Below are the steps (taken from Cordova) needed to update your > 3.0 projects to the latest version (3.5 as of this post).
In a command / terminal run:
npm install -g cordova
- Now go to into your project (ie: c:\projects\test) and run:
cordova platform update android (or ios)
You can update your plugins by removing / adding them again like:
cordova plugin rm org.apache.cordova.file
cordova plugin add org.apache.cordova.file
That’s it. Now you should have an up to date environment.
- Install node.js from nodejs.org (use default settings).
- Open a command prompt (cmd) and run:
- npm install -g phonegap
- npm install -g ant
- npm install –g cordova
- Now add ‘C:\Users\<yourusername>\AppData\Roaming\npm\node_modules\ant\ant\bin’ to the Path system variable
- Download and extract the Android SDK from https://developer.android.com/sdk/index.html
- I extracted to c:\mobile\androidsdk (referenced below as <yoursdkpath>)
- Add <yoursdkpath> + \sdk\platform-tools to the Path system variable
- Add <yoursdkpath> + \sdk\tools to the Path system variable
- Now to setup an Android image to emulate and test with:
- In the sdk folder, run Eclipse (ie: C:\mobile\androidsdk\eclipse\eclipse.exe
- Create or use the default workspace
- In Eclipse, under Window choose Android SDK Manager
- In the SDK Manager, make sure these are checked:
- i. Tools > SDK Tools, Platform-tools
- ii. Android <you choose the version> SDK Platform, Arm system image & Intel system image (if available)
- iii. Extras > Android Support Library, Google USB Driver, Intel x86 emulator HAXM
- Click Install x Packages, accept all licenses
- When downloads are finished, close the SDK Manager
- If you want to speed up the Android emulator, I suggest installing the Intel HAXM located at: \sdk\extras\intel\Hardware_Accelerated_Execution_Manager
- Now back in Eclipse (restart if you’ve installed the HAXM), you can go to Window > Android Virtual Device Manager.
- Click “New” to create a new virtual device
- Choose a name (anything you want)
- Choose a device (something simple like the “4.0” WVGA”)
- Choose a target (this is what you downloaded in step 4d).
- 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)
- Now you can click “OK”
- In the list of virtual devices, choose your new device and click “Start”
- Provided you don’t see any errors, after a few minutes (be patient) you’ll have a working Android emulator going.
- Now, let’s do a quick project and test it! Go back to cmd (your command prompt).
- Create your project with, run: cordova create hello com.ex.hello “HelloChris”
- Go to the project directory, run: cd hello
- Add android to the project, run: cordova platform add android
- To make sure your project is ok, run: cordova build
- Now if you don’t already have your emulator running, go back into Eclipse into the Android Virtual Device Manager and start your device.
- When it’s running, run: cordova emulate android
- That’s it; you should see “your” app on the emulator in a few seconds. (It reads “device ready” with a logo or something…).
Continue reading “Installing & starting with PhoneGap on Windows for cross platform mobile development”
To setup port forwarding (maybe you have IIS or Apache running in a VM and want to access from other machines or the host).
If you vm is setup with NAT like this:
…You can go to “Edit > Virtual Network Editor”, this brings up this:
If you choose “NAT” network type, and click “NAT Settings”, you can configure port forwarding like this:
Enter your port, VM IP, etc. Click “OK” a bunch of times and you should be good. Don’t forget about firewalls on the host and VM.