PhoneGap API Not Working – Android

PhoneGap is a fun and some what easy way for developers that don’t know Java to develop cross-platforms applications using HTML, CSS, Javascript, and a bunch of plugins that other developers that love Java. After hearing about PhoneGap, I decided to give it a try.

 

Issues To Watch Out For
If you are interested in or currently developing a PhoneGap application for the first time or are relatively new to developing with PhoneGap, then you may want to watch out for these issues that I had. It will save you hours of time wasted and frustration. One of the issues to watch out for is to make sure that your cordova.js version (www folder) and the cordova.jar (libs folder) are the same version. If you don’t use the same version, you might run into a error similar to s ‘Alert’ is undefined. Next, make sure that you have set the target Android version for the project. Another thing to watch out for is to make sure that you have added the permissions for the app to use the native functionality to your project. If you get the network not working error and the error mentions index.html, you might want to check to see if you are pointing to the index.html file like the code below. If none of those suggestions help, run through the creating a project and checking off that everything is done. I used the sources for references.

 

super.loadUrl("file:///android_asset/www/index.html");

 

References/Resources

  • – PhonegapCordova Tutorial for Sharing Code: http://devgirl.org/2012/07/16/phonegapcordova-templatetutorial-for-sharing-code-between-platforms/

 

  • – PhoneGap From Scrach: http://mobile.tutsplus.com/tutorials/phonegap/phonegap-from-scratch/

 

Here is a screenshot of my working test.
Alert