Monday, May 23, 2011

Starting a Project with Phonegap in Eclipse

Recently, a colleague was asking for assistance setting up a development environment.  The good news is that there are a number of tutorials that go in to detail about how to get started.  The bad news (which is good news too) is that because PhoneGap is advancing rapidly and gaining developer mind-share, these tutorials are getting outdated quickly.For the record, the one that I recommend at the moment is located at: http://wiki.phonegap.com/w/page/30862722/phonegap-android-eclipse-quickstart.  This howto doesn't require developers to set up git and ruby, and works with the latest build of PhoneGap.


Walking my colleague through these steps, it occurred to me that it would be much easier if someone created an Eclipse Plugin.    The good news is that someone did.  The installation is, with a minor exception, pretty straight forward.  

  1. Under the Help menu in Eclipse Helios,select "install new software"
  2. Enter the address:  https://svn.codespot.com/a/eclipselabs.org/mobile-web-development-with-phonegap/tags/r1.2/download in the Work With combo and click add.
  3. Give it a meaningful name such as MDS PhoneGap for Android Plug-In
  4. Here's where I ran into an issue.  The plug-in wants to install the JavaScript Development Tools (JSDT) and it was failing to install.  Unclicking this particular component allowed the installation to complete.

After completing the installation, you'll be able to start a new PhoneGap project by selecting File->New->Other->PhoneGap for Android Project.  The wizard allows you to specify local, web, internal, or git repository locations for the PhoneGap bits.  As a bonus, you can also opt to include the JQueryMobile or Sencha Touch in the project and build the sample application.  It's never been easier to get started with mobile development.

Monday, May 16, 2011

Use Android Open Accessory Without Android Programming

I have to admit, I find the Android / Arduino intersection to be the nexus of nerdliness.  I mean that in the best possible way.

For those unfamiliar with the Arduino, it's a micro-controller platform based on an Atmel chip that simplifies the process of processing input from a wide array of sensor input and controlling a similarly broad range of output devices ranging from lights and servos, to sound, etc.  Yes, there are more capable platforms and less expensive platforms, but the Arduino at around $30 is an incredible gateway to that larger world.  It allows folks like myself to skip the minutiae and get  right to the fun parts of physical computing.  I had a few years of college level electronics and had forgotten it all before I graduated.  Getting an Arduino and programming it to control the color of an RGB LED or respond to varying resistance from a flex sensor scratches a very geeky itch.

The fact that Google selected Arduino as the base platform for their accessory kit says a lot about the momentum of this micro controller platform.  It's unfortunate that they chose to make their android accessory kit less than 100% compatible with basic Arduinos, and bewildering why it costs $400.  The good news is that because of the broad range of support the Arduino has in the wild, many developers have already begun to hook up your vanilla boards to Android handsets.

Make magazine has been a great resource for all things Arduino and shared this link for an Android app that can communicate with your Arduino and vice-versa.  There's more great coverage on the significance of all of this at Make Magazine

Thursday, May 5, 2011

Enabling ADB (Android Debug Bridge) over USB to a Nook Color under Linux

I've replaced the stock software on my Nook Color with CyanogenMod7.  This is a modified Android 2.3 (gingerbread) image.  This has a number of advantages over the original distribution and even over the updated Barnes and Noble 2.2 distribution.  Notably it provides Bluetooth and a real Android market.

I wanted to enable ADB support so that I would be able to run applications directly from Eclipse on the Nook Color.

Before you do anything else:

  • Enable USB debugging on the device by using the Menu -> Settings -> Applications -> Development ->  USB Debugging.  If you don't do this, you won't even see the device listed under adb.  Note the vendor ID that's shown when you execute lsusb.



After doing this, I followed the instructions from http://nookdevs.com/NookColor_USB_ADB

The following command tells android that the nook color is an android device.  See the same vendor ID?

mkdir -p ~/.android && echo 0x2080 > ~/.android/adb_usb.ini && adb kill-server && adb devices
Now here's the tricky part for me....after executing adb devices, the nook color was showing as ??????? no permissions.  There were a number of workarounds for this, but I found that they were all running into similar issues.  Either they had the wrong vendor ID or they were using the wrong attribute name, or they were executing too early and were being replaced by the default udev rules.  In the end, I had to edit the udev rules as follows:


sudo vi /etc/udev/rules.d/90-android.rules
add the following text:

SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"
restart udev with

sudo service udev stop && sudo service udev start
restart adb from the platform-tools directory using

./adb kill-server && ./adb start-server

when you execute adb devices again, you should see your B&N Nook Color serial number and you'll be able to debug directly from Eclipse!

Wednesday, May 4, 2011

Free eBooks on iPhone / Android development with PhoneGap

Jonathan Stark has released books on developing mobile applications for iOS and Android.  These books are free to read for a limited time on the O'Reilly Open Feedback System.

Monday, May 2, 2011

Utilizing Hybrid Toolkits for mobile development

In my previous posts, I touched on the fact that Mobile Web applications have a wide reach across a range of devices, but fail to benefit from the mobile device capabilities.  This is contrasted with application development using native SDKs which have full access to the mobile device, but are restricted to a single platform.

Hybrid toolkits find that sweet spot in the Venn diagram where the device capabilities and device independence meet.  Two such toolkits are PhoneGap and Appcelerator Titanium.  Each of these tools allows you to access the sensors and work with the device capabilities of Android and iOS devices.  In addition, PhoneGap has support for BlackBerry, WebOS, and Symbian with beta support for Windows Mobile.  Appcelerator is currently in beta on their Blackberry Support.

Each of these tools allow you to develop mobile applications with JavaScript.  PhoneGap applications are hosted in a Webkit browser.  Appcelerator applications benefit from compiling down to native controls for the destination platform.  Both tools allow developers to interact with the mobile devices including:  SQLLite databases, local storage, sound recording and playback, location (network/GPS), camera, orientation, vibrate, and accelerometers.

Both tools are supported by Android Market and Apple's App Store.  Both tools are free and open source.  This means that you can download them BOTH and try them out to see what you like.  Both toolkits have similar feature support on Android and iOS.  PhoneGap gets a nod for widest device support and Appcelerator gets a nod for native control support.  Right now, I've found that the PhoneGap documentation seems more complete and well written, but I think both tools have a tremendous amount of potential.



I'm working on some demo applications right now and hope to post some details soon!