DISCOVER
X

Cordova Installation in Windows 8 Part 2

August 31, 2014 4:01 pm Leave your thoughts
Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail

Contributed by Arthur K

Continuing from part 1, we will now setup Apache Ant, Android SDK and prepare our first application.

Apache Ant

The easiest way to install Ant is using “npm install –g ant”, but somehow on my machine it only installed version 1.8.4 and would not work with current JDK version that we installed before. I found that there is a zipped latest version (currently 1.9.4), in their website that you can download.

Download Apache Ant here: http://ant.apache.org/bindownload.cgi

If you already installed Ant using npm, you can overwrite the file created using files from the zip file you just downloaded. Usually it is installed under:

If this is your fresh install, you can put it under any preferred directory. However you will need to take a note on the installation directory as we will need to add it on the PATH environment as we did with Java in part 1.

If above code is not working when you entered it on command prompt, means you need to add Ant to your environment PATH.

On the System variables:

It is important to replace <Username> with your username. Try to browse the directory to confirm you get the right one up until you can see “bin” directory.

On User variables for <Username>:

Again, it is important not to delete or modify your previous PATH value, only append and use “;” as a separator from your existing PATH values.

You would need to double check if you can run “ant –v” on command prompt and getting return of “Apache Ant(TM) version 1.9.4 compiled on April 29 2014”, otherwise you would end up receiving Cordova error when trying to add platform on your application.

Android SDK

This is the final step before we are able to use Cordova to create our apps. The good news is that there is a new IDE based on the famous IntelliJ, called the Android Studio that you can download for free. The choice is yours of course whether to install an IDE package or just the SDK.

Download Android SDK here: https://developer.android.com/sdk/installing/studio.html

Follow the installation steps and when its done, add the directory path to your environment PATH using same way as previously done with Java and Ant.

On the System variables:

It is important to replace <Username> with your username. Try to browse the directory to confirm you get the right one up until you can see “tools” directory and “platform-tools”

On User variables for <Username>, we need to add two path to the “tools” directory and “platform-tools” directory:

Again, do not to delete or modify your previous PATH value, only append and use “;” as separator from your existing previous PATH value.

After adding two paths above, you can run “android” on the command prompt to bring up Android SDK Manager to download and install all files under “API 19” needed by Cordova version 3.5.0. This process will take a while depends on your internet connection speed as the files are quite large.

Preparing Your First Android Application

Finally we reached the most exciting part, preparting your Android application. Navigate to your preferred directory where you want to develop your application, then use the Cordova create command.

where:

<directory> is your future app directory, for example “supreme”

<id> is the optional identifier of your application, for example “com.example.supreme”

<title> is the optional title of your application, for example “Supreme”

Therefore, altogether it would be:

This Supreme apps is still blank and a target platform would need to be added inside. In this case we want to build an Android app. We will need to navigate to supreme folder.

Then add the android platform inside our application directory.

That’s it, preparing your first app is very simple. In the upcoming posts we will talk about building your first application.

Possible Problems

Here is a list of common problems and the ways to fix them.

Ant not found

Cordova error below when trying to add platform on your application.

This problem happens because PATH environment is not setup properly under local machine. The easiest way to check whether you get the correct path is by browsing using explorer up until you see “bin” directory of Ant.

For my local machine, it would be under:

Set environment as follow,

System variables

Append PATH value on User variables for <Username>

Error javac1.8

Cordova cannot build android error javac1.8

This problem happens when ant version <1.9.0 is used which is not compatible with current JDK 8. It is can be easily solved by updating Ant to latest version available from web.

Closing

That’s it for installation of cordova under Windows 8. Stay tuned for the next chapter in the Cordova contribution, which is creating your first application.

 

 

Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail
Tags: ,

Categorised in: , ,