Preparing for Android Export

Last Updated: 22/11/2020


NOTE: This "Legacy" section is old and is now meant for Advanced Developers who want to export using the Cordova CLI.
For most users, "Firebase Auth Pro Mobile" Plugin is recommended.


1. Install NodeJS

Go to https://nodejs.org/en/ and install the package.


2. Install Cordova

Open Terminal and paste the following line and wait till the operation finishes:

npm install -g cordova


I also installed Powershell 7 (in Windows) additionally because you can just right click and open Powershell in the folder you are currently in.

Using older Powershell, you will have to type the whole location of your Cordova Project folder every time which is a real pain.

https://github.com/PowerShell/PowerShell/releases/tag/v7.0.3


3. Install JDK 8

Windows:

  1. Install Chocolatey. Run Powershell as Administrator and run this line:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

2. After installation is complete, run this line as Administrator to install JDK 8:

choco install jdk8

3. Right-click This PC (or My Computer) > Properties > Advanced System Settings> On Advanced tab, click Environment variables.

4. Check if JAVA_HOME variable exists. If it doesn't find the directory where JDK has been installed in your system. It is usually located at C:\Program Files\Java\jdk1.8.0_211


macOS:

  1. Install Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Install JDK 8: (Not Tested. If not working, report)

brew cask install java


4.1 Install Android SDK using Android Studio

Download and install Android Studio from https://developer.android.com/studio

4.2 (Alternative) Installing Android SDK Manually
(works on low end PC. Tested on 3GB RAM x64 bit)

Windows:

1. Download and Install https://dl.google.com/android/installer_r24.4.1-windows.exe

2. Update Android SDK Tools:

2.1. Download and extract https://dl.google.com/android/repository/emulator-windows-6755297.zip

2.2. In the Extracted Folder, navigate to the emulator Folder, Select and Copy the contents

2.3. Navigate to your android-sdk directory. It is usually located in C:\Program Files (x86)\Android\android-sdk\tools Here, paste and replace all the contents you had copied.

3. Run Android SDK Manager as Administrator.

4. Find and download Android SDK Build-tools (latest) , Android 9 (API 28)- SDK Platform

macOS:

  1. On macOS, you have to download Android Studio, and then Android SDK Manager will be installed. https://developer.android.com/studio

  2. Find "Android 9 (API 28)" and just download "SDK Platform"


Install Gradle

Windows:

Make sure Chocolatey is already installed. Run Powershell as Administrator and paste this line:

choco install gradle

macOS:

  1. Make sure Homebrew is already installed. Run this line in the Terminal:

brew install gradle


Locate your Cordova project

Navigate to your exported Construct 3 Cordova project folder and open terminal.

If terminal is not available on right click, open terminal and type the folder location like in this example:

cd "D:\Cordova Projects\New project"


Add Android Platform to your Project

Previously we downloaded Android 8.1.0 SDK Platform. Now run the following code to add this platform to your project:

cordova platform add android@8.1

If you are performing this task for your first time, check if all requirements are met.

cordova requirements

If all requirements are met, it should look something like that.

If not, check if you have missed something in the steps above.

Once everything is successfully set up, you won't need to check every time for your the next project builds.