When writing applications that need to be run in different platforms, it looks more straightforward to focus all the efforts in a solution that can work in all of them.
How to solve the problem of writing applications in multiplatform environments?
There are, however, 2 problems:
- Bad performance of web applications compared with native apps.
- Lack of a system to access to native funtionalities like GPS.
Phonegap tries to solve both problems.
Phonegap is an open source framework for the development of applications that can run multiplatform in mobile phones: Android, Iphone, Blackberry.
Phonegap provides access to native functionalities such as GPS, vibration, etc. In theory with the same code that access to those features you can target different platforms.
This sounds, in theory very well, but we'd need to try. Let's start:
Configuring IDE and the Android SDK
Install Eclipse >= 3.3 (I've tried version 3.4 Ganymede).
Install Android SDK
Add the Android SDK to the PATH env variable:
- Install the Eclipse plugin, adding the Android repository
- Finally, we need to create a virtual machine using the command
androidthat it's available in the Android SDK's tools folder.
android create avd --target 2 --name my_avd
If we haven't added the PATH env variable, it can also be set in the Eclipse preferences (android section).
2. Setup Phonegap
Following those simple steps, we have now a first part ready. Now we can install Phonegap and try the hello world example.
There are 2 ways of installing Phonegap, I recommend to use directly git cloning its repository since. The reason is that it's a project that is under heavy development and the git version is more updated.
git clone git://github.com/sintaxi/phonegap.git
Now we can start playing, let's create a new project choosing the option of loading it from a template. The target must be Google API's (id 3). We need to make sure that the virtual device we have created is compatible.
Playing with the Phonegap framework I found some problems related with the
bindBrowser method in the
appView. After some troubleshooting I did a workaround, just commenting some code in the
// sensorManager =(SensorManager) mCtx.getSystemService(Context.SENSOR_SERVICE);
I implemented a twitter client to show trending topics in 15 min, without forgetting of course 45 min. initially spent configuring Phonegap.
Looks really good, and seems to be under active development. Let's keep an eye on the project.