This is a short guide on how to setup a working and testing environment for either native or Phonegap/Cordova based Android app development on a Windows machine.
NOTE: the versions of the software I list here are the current versions available as of this article’s posting, or my personal preference.
To get you on your merry way of building android apps via Phonegap on Windows 8/8.1 you’ll be needing the following software:
- Java SDK (7u75)
- Android Studio (v1.1.0)
- Node.js (v0.12.0) – choose the Windows Installer (.msi)
- Apache-Ant (1.9.4)
Now we set things up one at a time…
Install the JDK first since it is required by both the Android Studio and Apache-Ant. After installing take note of the installation folder which is typically in C:Program FilesJavajre7, we will be appending this to our PATH environment variable later on. We will need this to access the Java keytool for signing our apps.
After installing this in your preferred settings open the SDK Manager and check the tools you’ll need. This is dependent on which version of android you plan to support; also make sure to select ARM-EABI System image for each version of android you on using. If your system supports Intel Virtualization be sure to check Intel x86 Emulator Accelerator as well. Now that you’re done click on Install Packages.
While that’s downloading we will setup paths. Navigate to System Properties (you can search system environment in Windows 8 to open the dialog) then click on Environment Variables. Once there we will be adding some variables, you may choose to either add it globally or for the current user.
Add the variable ANDROID_HOME with value of the SDK path found in the SDK Manager dialog (see the image up top). After that you’ll want edit the PATH variable and append the path to Android’s tools and platform-tools folder like so (note the semi-colon as the separator)
Notice the ANT_HOME variable? to save time we will segue a bit and set this up now. Simply extract the apache-ant archive to your preferred location, this will be the value of the ANT_HOME variable (e.g.C:apache-ant-1.9.4).
We also added the the bin folder location of our Java SDK which is in the installation directory we noted earlier.
That’s it! Just remember that we also appended the %ANT_HOME%bin to the PATH variable as well.
Before proceeding any further open your commend prompt and test to see if the paths are properly set by echoing each variable you added/changed (e.g. echo %ANDROID_HOME%). You may have to restart your system for the variables to take effect. You may also try the “ant -diagnostics” command without quotes to see if the paths for it are correct. You may encounter an error like Unable to locate tools.jar. which you can ignore.
Assuming that the packages are done downloading and installed. If your system supports Intel Virtualization (VT-x, VT-d). proceed to your Android SDK folder then look for the Intel x86 Emulator Accelerator which is typically in extraIntelHardware_Accelerated_Execution_Managerintelhaxm-android.exe and install it manually.
If you are getting errors during installing despite having support for Virtualization:
- check if you are running Hyper-V (a Windows 8 Pro feature) and disable it in the control panel.
- if you are running Avast, navigate to Setting > Troubleshooting then uncheck Enable Assisted Hardware Acceleration.
Now proceed to Tools > Android > AVD Manager (Android Virtual Device) in Android Studio and ad a virtual device for testing. For the System Image setting it is much faster to use the x86/x86_x64 if your system supports Virtualization; if not choose the ARMEABI albeit really slow.
Node.js and Phonegap
After installing Node.js locate and open the Node.js command prompt shortcut then install phonegap and cordova by executing the commands below. This will download and install the latest versions of the packages.
npm install -g phonegap
npm install -g cordova
once that is done, you can now start building and testing phonegap apps.
Phonegap Build caveat
There is also a Phonegap build service you may use for free.Simply supply your html files in zip format from either a public repository or by uploading them to their servers and in turn will supply you with a compiled app for the platforms you choose.
The disadvantage being that you will have to upload files every time you want to rebuild/debug the source. It doesn’t not provide emulation or testing environment either; So what ever time you save skipping the setup of your development environment will be negated sooner than later when you start to test.