Setting up a development environment for Android & Phonegap on Windows

Let me preface here by saying I’m personally platform agnostic, I’ll use whatever gets the job done and whatever is available. But the fact of the matter is that Windows is still the dominant operating system and often people just can’t get away from it, for whatever reason.  If you are developing mobile applications, Linux is your friend and if you want to ever deploy to an iOS device, you pretty much are required to have a Mac.  (I’ve found a way around this that I might blog about at a later date).

For now I’m going to focus on the Windows 7/8 user who wants to make an application for an Android device… the most important piece is setting up a development environment.  My instructions below were drafted using my Windows 7 existing development environment, then refined using a from scratch Windows 8.1 Virtual Machine installed with nothing on it.  Without further ado – how to get your development environment ready for making Android Apps.

REQUIREMENTS:

  • Windows 7 or Windows 8 Operating System
  • Internet Connection
  • Some working knowledge of using the windows command line interface
  • Some working knowledge of editing windows environment variables such as PATH

HELPFUL TIPS:

  • Pin the windows command prompt to the taskbar. You may be opening and closing this often, especially in Windows 8, pinning the cmd.exe to the taskbar or creating a desktop shortcut is a tremendous time saver.
  • If you will be testing on an android mobile device, make sure that the device is in USB developer mode.

SETTING UP THE ANDROID/PHONEGAP BUILD ENVIRONMENT:

1. Download and Install Java (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)

Download and install a recent release of the Java SDK for your computer. You should be able to open a new instance of cmd.exe and run java without problems. If you cannot run the “java” command from your command line then you may need to add the Java PATH to your system environment variables.

2. Download and install Git.

Having Git installed will be important for adding cordova plugins from Git repositories. If you do not already have one installed, the following git client works well: http://git-scm.com/download/win

When you install Git during the process you will be given a choice for adjusting your PATH environment. You will want to select the 2nd option “Use Git from the Windows Command Prompt”. This will allow cordova to use git for installing plugins later on. If you do not select this you may need to add Git to your windows environment variables later on.

3: Download & Install Apache Ant

Apache Ant is needed by Android and Cordova for building projects.

Download and extract this zip file somewhere on your computer: http://mirror.tcpdiag.net/apache//ant/binaries/apache-ant-1.9.4-bin.zip

Add the full path to the bin/ folder to the end of your PATH environment variable.

4: Install the android SDK: http://developer.android.com/sdk/index.html#Other

5: Potentially Add Android to PATH (EXE SDK installer may do this automatically)

We need to tell Windows where our Android SDK lives.

Open up your environment variables setting and add the full path to both the adt-bundle/sdk/platform-tools/ folder and the adt-bundle/sdk/tools/ folder to the end of your PATH variable:

6. Use the SDK Manager to update tools and setup important extras such as oem-usb-drivers which will allow you to connect an android device via usb to build an app on.

a) Run the manager – located the Google USB Driver under ->Extras

7. Install or update Node.js

Download the most recent version of Node.js. (http://nodejs.org/) If you are running an older version of Node, make sure to update it because older versions had issues with npm.

As with the other commands, nodejs should now function in cmd.exe but just to be careful, add the full path to the bin folder in Node to your PATH, which will look something like C:\Program Files\nodejs\.

8. Open a new cmd.exe window, and run:

$ npm install -g cordova

The -g flag above tells npm to install cordova globally. Otherwise it will be installed in the node_modules subdirectory of the current working directory. You may need to add the npm directory to your PATH in order to invoke globally installed npm modules. On Windows, npm can usually be found at C:\Users\<username>\AppData\Roaming\npm.

9. At this point you have the base development environment for any phonegap android application.

 

ADDITIONAL REQUIREMENTS:

1. In order to deploy your application to an attached USB Device you need to make sure that the Google USB Driver from the Android SDK is installed and that your device manager has the driver installed for the device.

2. The device will also need to be in USB developer mode.

3. Instructions as follows:

http://developer.android.com/sdk/win-usb.html#top

a. run C:\path\to\Android\sdk\SDK Manager.exe
b. Located “Extras” and add the Google USB Driver Package
c. Using these instructions make sure your device is connected via USB and the driver is updated: http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver

 

CONCLUSION:

I intend to make some followup edits to these instructions with some screenshots and maybe even a video… and then, when it is ready for deployment in the very near future (March/April 2015) I will talk about the project that I am working on that will integrate into this build environment after it’s next release..  I previously blogged about Atmosphere if you want to catch up on that.

I know a lot of people as well as myself, who have needed a path to Android development on Windows PC… hopefully these instructions help you get setup in a simple and effective manner.

Leave a Reply

Your email address will not be published. Required fields are marked *