Tuesday, March 10, 2015

Running Apache Cordova (formerly Adobe PhoneGap) on Windows

To build cross platform mobile apps based on web apps, Apache Cordova (formerly Adobe PhoneGap) is handy. This is a basic guide, so expect naive suggestions.

You might want to use the cloud build service instead of following this steps.

Requirements (customized from http://phonegap.com/install/)
1) Launch   NodeJS installer from administrator command prompt (must for Win8)
2) Disable desktop.ini and thumbs.db  (otherwise builds will fail)
Disable creation of desktop.ini from windows registry
Disable Windows thumbs.db files from being created
3) Install Git, choose custom, install optional UNIX tools that replaces sort/find.


Instructions from step 4 assumes there is no proxy. For proxy, follow (adapted from)
npm config set strict-ssl false
npm config set registry "http://registry.npmjs.org/"
npm config set proxy http://proxy:port_here
npm config set https-proxy http://proxy:port_here
npm --proxy http://proxy:port_here install -g packagename



4) Install ant from command line:
npm install -g ant
5) Install PhoneGap from command line:
npm install -g phonegap
6) Install Cordova from command line:
npm install -g cordova



If your proxy is 192.168.1.15 and port is 8080, it would look like
npm config set strict-ssl false
npm config set registry "http://registry.npmjs.org/"
npm config set proxy http://192.168.1.15:8080
npm config set https-proxy http://192.168.1.15:8080
npm --proxy http://192.168.1.15:8080 install -g ant
npm --proxy http://192.168.1.15:8080 install -g phonegap
npm --proxy http://192.168.1.15:8080 install -g cordova




7) For Android development,
7.1) install JDK (choose 32/64 bit as appropriate)
7.2) ensure system PATH variable is set to find java inside bin directory and JAVA_HOME is set to the directory/folder above the java bin folder
7.3) install Android SDK or Studio (SDK+IDE) matching JDK 32/64 bit
Set ANDROID_HOME
https://spring.io/guides/gs/android/
http://stackoverflow.com/questions/26356359/error-android-home-is-not-set-and-android-command-not-in-your-path-you-must-ful




8)  In case this is your first time installation of app outside google play store, in your android phone,
Open "Settings" from the Apps screen or notification bar, and then choose "Security."
Scroll down to Device Administration, and then check the "Unknown Sources" option.

9) Read PhoneGap documentation and follow up to (including) Command line interface
Before each build, search in your project directory/folder and delete desktop.ini and thumbs.db in case they came while copying/pasting folders. You might have to enable showing hidden files.

Test in emulator:
c:\>   cordova emulate android
Test in device:
plugin android phone to a USB2.0 port in your PC
c:\>   cordova run android

10) If you share the files over email / link, tell them, when prompted, to choose "Package Installer" or "Verify and install" to launch setup. Both works. Then to Click open. Sometimes installation from email attachments fails, it might be a good idea to upload somewhere and share the download link.