Getting an android app running with Phonegap 3.0 on Windows 8

With 3.0 version, the installation of phonegap has changed.  You can no longer download the binaries from the website.

As given in the installation page,  you need to first download and install NodeJS.  Then run the commands to install phonegap.

The Usage instructions did not work for me at all though I had Android SDK on my system.   "android" command was not in the PATH.

Why?  That was possibly because I had not downloaded and installed the ADT Bundle.   I already had an Eclipse installation. When I needed to install the Android SDK, I chose the "Use the existing IDE" option, downloaded the installer and ran it.

Now where was the SDK installed?  I located it at C:\Users\me\AppData\Local\Android\android-sdk. I added the tools and platform-tools subfolders of this location to the PATH, after which I could.

Thereafter the usage instructions ran fine.  Now how do I see the app on an emulator?  There are two options - command line using cordova or using Eclipse.

The newer version of Cordova is installed using Nodejs. Once done, running

cordova emulate android

showed up the sample application on the configured Android Virtual Device (AVD).

In fact, cordova offers an alternate way to bootstrap a new android project as documented in their command line interface.   As it turns out, I spent considerable time figuring out what went wrong when I followed their instructions blindly - specifically the following line:

cordova create HelloWorld com.example.hello "Hello World"

Subsequent commands

cordova add platform android
cordova build 
cordova emulate android

ran without any error, but I did not see the application in the simulator.

I thought there is something wrong with the command line and opened up the project in Eclipse.  It give a bunch of errors as below:


I manually resolved everything and got the application to work finally, but wondered what the problem was.

The clue was in the line

The other two arguments are optional: the com.example.hello argument provides your project with a reverse domain-style identifier, and the "Hello World!" provides the application's display text. You can edit both of these values later in the config.xml file.

When I omitted these parameters, the application worked fine from the command line.  I decided to run the cordova commands in debug mode (-d) and compared the output with and without the optional parameters.  That is when I saw that build.xml file was not being generated when the second optional parameter "Hello World" was specified.  Changing that to "Hello" worked great as well - it looked like a problem with the space!

So much for my first day with phonegap and android.


Comments

Popular posts from this blog

Opening a safe deposit locker in SBI

Opening a Kannada Word document

Switching to Tatasky make my pack