Android Platform Guide

android-platform-guide

android-platform-guide

android-platform-guide

User Manual: Pdf

Open the PDF directly: View PDF PDF.
Page Count: 4

A brief overview of install and setup for Android with Cordova.
Intro
Check Cordova requirements
Android requirements and environment setup
Create basic app
Add Android platform
Build basic app
Emulate app
The following brief guide assumes you have Node.js, NPM, and Git installed and
working correctly on your local system. Then, you'll need to ensure you have the latest
version of Cordova installed and working correctly.
These checks and requirements are per platform, for example for development with
Android.
Initially, we can check required and installed dependencies for Cordova with the following
command,
cordovarequirements
This command will check build requirements for each install platform, e.g. Android.
Before installing and configuring Android, we need to ensure that the latest version of the
Java SDK is available,
update java to latest se version, e.g. 1.8.0_102
update ~/.bash_profile
#CreateaJAVA_HOMEvariable,locationdetermineddynamicallyaspartofinstall
exportJAVA_HOME=$(/usr/libexec/java_home)
#AddthattotheglobalPATHvariable
Cordova - Guide - Android Platform Guide
Contents
Intro
Check Cordova requirements
Android requirements and environment setup
n.b. this will add Java path &c. for latest Java version...
Then, we can start to setup our Android environment,
download Android Studio
install and follow prompts for default install and setup
if installing just the Android SDK, add the directory location of the SDK's tools and
platform-tools to PATH
e.g.
add ANDROID_HOME to path in ~/.bash_profile
exportANDROID_HOME=~/Development/android-sdk/
exportPATH=$PATH:~/Development/android-sdk/platform-tools/
exportPATH=$PATH:~/Development/android-sdk/tools/
exportPATH=$PATH:~/Development/android-sdk/build-tools/
then setup an Android Virtual Device (AVD) for use as an emulator
follow guide at https://developer.android.com/studio/run/managing-avds.html
open Android Studio
select option for AVD manager from toolbar for open project (normally 4th from
the right)
follow prompts and choose preferred specific device or generic device type
choose required Android platform, e.g. Android 6.0, SDK 23
Or, we can issue the following command to use the AVD manager directly
androidavd
However, latest AVD definitions (incl. Nexus 5x, 6P...) are available using AVD manager via
Android Studio 2.1.
To test the new Cordova install, we can now create a simple initial app
cordovacreatetestcom.example.testTestApp
This command will create a new app with its own basic, shell template for the app's
underlying structure. The home page for this app will be stored in www/index.html.
exportPATH=${JAVA_HOME}/bin:$PATH
Create basic app
Add Android platform
For a chosen project, we can then add required platforms for our application. These are
the mobile OSs the app needs to run on, and Cordova will support. We can add the
Android platform with the following command from within the root directory of our
Cordova app,
cordovaplatformaddandroid--save
We can then check all current install platforms with the following command,
cordovaplatformls
Each platform added to a project is stored in the app's /platforms/ directory. These
files are maintained and updated as part of the build and update process run by Cordova
for the current app.
After creating our basic test app, we can now build it from the directory created for the
app.
cordovabuild
This command will build the current app for the installed platforms. However, we may also
wish to limit the scope of a given build to a specific platform, e.g.
cordovabuildandroid
We can also build our app, and then open it for testing with an installed emulator
cordovaemulateandroid
This will choose the default installed emulator for the chosen platform. However, we may
also wish to add a flag for a specific emulated device,
cordovaemulateandroid--target=Nexus_6P_API_23
This will load the app in the specific emulator for the Nexus 6P.
Example app loaded in emulator,
Build basic app
Emulate app

Navigation menu