Create APK and Use Cordova Plugins
ASG-Zenith mobile application is a hybrid app based on Cordova cross platform mobile library. Cordova library provides the necessary bridge code for the HTML or Javascript based applications to communicate with the mobile device features. These bridge components are called Cordova Plugins, and are available for different native features in Cordova Open Source project and from third party implementations.
ASG-Zenith platform supports a variety of native device features like camera, file etc. However, there may be use cases for business applications to leverage other features beyond the supported ones. This document explains how to integrate Cordova plugin and use the features provided by the plugin with in ASG-Zenith applications.
ASG-Zenith provides mobile app support for ASG-Studio (design time) and ASG-Zenith Portal (runtime).
Perform the following steps:
- Navigate to ASG-Studio installed location and extract the
BuildTool.zip
file. The typical path where theBuildTool.zip
file available isC:\Program Files (x86)\ASG STUDIO\mobile\android
. - Download Android Studio 4.0.1 or higher from the below link and install on the same computer where ASG-Studio is installed.
- Launch Android Studio and setup the following:
- Set Android platform to a version between 6.0 and 10.0.
- Set SDK tools to a version 26.0.0 or higher.
- Configure Phone or Tablet as Virtual Device and set 6.0 or higher as Android version.
- Download Gradle 6.5.1 from the below link on the same computer where ASG-Studio and Android Studio are installed.
- Extract the contents of downloaded gradle-6.5.1-bin.zip file to the following location:
- Set the following environment variables and assign Android SDK folder path in System Variables:
- ANDROID_HOME
- ANDROID_SDK_ROOT
-
Add the path of the Zulu JDK that you installed alongwith ASG-Studio, in the Path environment variable of System Variables.
- Launch the command line interface and change the directory to the path where the BuildTool folder is extracted as per step 1. For example,
C:\Program Files (x86)\ASG STUDIO\mobile\android\BuildTool
. - Run the following command to download and install the latest available version of Cordova CLI:
- Add needed platform using
cordova platform add android
. - Build using cordova build android.
- Add the required Cordova plugin using
cordova plugin add <plugin>
. - Create a
javascript
file to include required functionality from imported plugin. You must export all the functions via a single variable. Yourjavascript
file looks similar to the example shown in the image below: - Add the
javascript
file as external script in an UI model. You can use all the available features fromjavascript
file. For example, as shown in the above image invokingcontacts.search
allows to call thesearch function
. navigator.userAgent.toLowerCase().match(/android.*applewebkit(?=.*version)/);
navigator.userAgent.toLowerCase().match(/\(ip.*applewebkit(?!.*(version|crios))/);
- Test your application for the native features using ASG-Studio mobile app and fix the issues if you find any.
https://developer.android.com/studio
https://gradle.org/next-steps/?version=6.5.1&format=bin
.\Android Studio installation folder\gradle\gradle-6.5.1\.
npm install -g cordova