Tutorial 12: Using PhoneGap to create an Android .apk App

June 19, 2012

© 2013 NS BASIC Corporation. All rights reserved.

Purpose

The purpose of this tutorial is to show how to use PhoneGap to turn an NSB/AppStudio project into a native Android app.

Normally, NSB/AppStudio produces Web Apps, which are installed through the browser and can be saved to the Home screen. If you want to create an app which is distributed as an Android APK file, you need to compile it using the Android SDK. PhoneGap lets you do this with no change to your code.

PhoneGap also gives you access to features that are not available to NSB/AppStudio. These include the camera, compass, contacts and notication. In addition, you can develop your own native code extensions. Here's a good introduction to creating PhoneGap plugins.

PhoneGap has two methods of doing this. The easier one is PhoneGap Build. Use "Build Native App on the Run menu to upload your project to their site. In a few minutes, you can download app-store ready apps for Apple iOS, Google Android, Palm, Symbian, BlackBerry and more.

The more complex method is the PhoneGap SDK. You will need to download the full development SDK, install and configure, then compile on your own machine. This method is free, but can be time consuming and tricky to set up.

Here is a full comparison of Web Apps vs. PhoneGap apps.

1. PhoneGap Build

To use PhoneGap Build, choose "Build Native App" under the Run menu. Your app will be uploaded to PhoneGap's compilation service. You can check on the status of the builds using "Get Native Build Status". Files are usually ready to download in a minute or so.

PhoneGap Build will produce a .apk file, which you can then install on your device.

NSB/AppStudio installs with a demo PhoneGap Build account. You'll want to set up your own account to use. It's quick and easy to do.

2. PhoneGap SDK

The best instructions we have seen for using the PhoneGap SDK are on PhoneGap's website.

In your PhoneGap project's folder, you will have a www folder. On the Deploy Options screen, use the 'Deploy to local or DropBox public folder' option. Put path of the www folder in 'Local Path'. Deploy will then copy the proper files into the www folder.