5 minutes reading time (910 words)

How to install the developer tools to build Android apps with Cordova

Construct 2/3 lets you build Android apps using a technology called Cordova.

Ok, but what is Cordova?

Cordova is an open-source mobile development framework. It allows you to use standard web technologies - HTML5, CSS3, and JavaScript for cross-platform development. You can see all the details at https://cordova.apache.org

Through a series of blog entries, I'm going to describe how to use the Cordova CLI (command-line interface) to build Android apps locally. Although it's not easy to work with it, the Cordova CLI allows full control over the build process, offline builds and use of any third-party Cordova plugins.

This entry will cover how to install the tools needed for the build process.

  1. Prepare our Windows system
  2. Install Node.js
  3. Install Git
  4. Install Cordova CLI
  5. Install Java SE Development Kit 6
  6. Install Java SE Development Kit 8
  7. Install Android Studio
  8. Configure Android SDK

1. Prepare our Windows system

Our clean slate it's going to be a fresh install of Windows 10 Professional October 2018 Update

Version: 1809
Build: 17763.292
Architecture: x64

This way we can guarantee there will be no Windows related errors.


2. Install Node.js

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine.

We're going to download Node.js version 10.15.0 from https://nodejs.org/en/
Be sure to select the x64 version.

Now we're going to install it using the default settings.


3. Install Git

We're going to download Git version 2.20.1 from https://git-scm.com/download/win
Be sure to select the x64 version.

Now we're going to install it using the default settings.


4. Install Cordova CLI

We're going to install the Cordova CLI version 7.1.0

Ok, but why install the old v7.1.0 instead of the newest one?

The plugins that I use (cranberrygame) haven't been updated so they aren't compatible with Cordova v8.0.0. To be more specific, those plugins need to be added to the Cordova project with the parameter --nofetch in order to use the plugin architecture of Cordova versions previous than v7.0.0.

Extract taken from Cordova's blog:
Starting with Cordova v7.0.0:
Fetch is now the default method for fetching platforms. Fetch uses your system npm to npm install modules into your project. The --fetch flag is no longer required. Use the --nofetch flag to revert to pre-Cordova@7.0 behavior (npm install is not used to fetch modules).

You can see all the details on the release notes:
https://cordova.apache.org/news/2017/05/04/cordova-7.html

Extract taken from Cordova's blog:
Starting with Cordova v8.0.0:
Removed --nofetch flag. Now all of our dependency fetching happens via cordova-fetch. This allowed us to drop the npm@2 dependency we were shipping with cordova. Instead, we now just use your system npm to do all of our fetching.

You can see all the details on the release notes:
https://cordova.apache.org/news/2017/12/18/tools-release.html

To install the Cordova CLI open a command prompt window and type npm install -g cordova@7.1.0


5. Install Java SE Development Kit 6

We're going to download Java SE Development Kit 6 Update 45 (which is the last version of the Java 6 series) from Oracle Archive Downloads
Be sure to select the x64 version.

In this case, we don't need the "Public JRE" feature, so we deselected it from the setup, for the rest we'll use the default settings.


6. Install Java SE Development Kit 8

We're going to download Java SE Development Kit 8 Update 202 from Oracle Archive Downloads
Be sure to select the x64 version.

Now we're going to install it using the default settings.


7. Install Android Studio

We're going to download Android Studio 3.3 from Android Developers
Be sure to select the x64 version.

Now we're going to install it using the default settings.


We're going to start Android Studio after it has been installed.


In this case, we're not going to import settings.


Now we're going to setup Android Studio using the default settings.


We verify the settings and proceed with the installation.


8. Configure Android SDK

Installing the Android SDK doesn't automatically include all the minimum required packages for developing. While individual developer needs vary you should install the "SDK Platform" for the Android versions you've set as minimum & target.

Example #1
Target API 23.
Minimum API 23.
Only need to install SDK Platform for API 23.

Example #2
Target API 23.
Minimum API 15.
Need to install SDK Platforms for API 15 and 23. Note that you don't need to install the API levels between the minimum and target (even if you are backporting to those API levels).

The list of Android API Levels can be found here:
https://source.android.com/setup/start/build-numbers

For a complete discussion on this you can visit:
https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/questions/install-android-sdk-packages

Now, let's suppose that we are developing 5 apps with the following properties:

App #1
Target API 20.
Minimum API 16.

App #2
Target API 25.
Minimum API 16.

App #3
Target API 25.
Minimum API 19.

App #4
Target API 26.
Minimum API 21.

App #5
Target API 26.
Minimum API 26.

The SDK Platforms that we need to build those 5 apps are 16, 19, 20, 21, 25 and 26. To install them we start Android Studio, select "Configure", "SDK Manager", then select the API Levels that you have established for your apps and click "OK".


We confirm the installation.


Finally, we accept the agreement.


Now, we should have our developer tools installed and ready to go.

In the next entry, I'm going to describe how to export from Construct 2 and build using the Cordova CLI.

Why I chose HTML5?

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Guest
Sunday, 17 February 2019