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:

  1. Navigate to ASG-Studio installed location and extract the BuildTool.zip file. The typical path where the BuildTool.zip file available is C:\Program Files (x86)\ASG STUDIO\mobile\android.
  2. Download Android Studio 4.0.1 or higher from the below link and install on the same computer where ASG-Studio is installed.
  3. https://developer.android.com/studio

  4. 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.
  5. Download Gradle 6.5.1 from the below link on the same computer where ASG-Studio and Android Studio are installed.
  6. https://gradle.org/next-steps/?version=6.5.1&format=bin

  7. Extract the contents of downloaded gradle-6.5.1-bin.zip file to the following location:
  8. .\Android Studio installation folder\gradle\gradle-6.5.1\.

    If the gradle\gradle-6.5.1\ folders are not already available, create the same within Android Studio installation folder.
  9. Set the following environment variables and assign Android SDK folder path in System Variables:
    • ANDROID_HOME
    • ANDROID_SDK_ROOT
  10. Add the path of the Zulu JDK that you installed alongwith ASG-Studio, in the Path environment variable of System Variables.

  11. 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.
  12. Run the following command to download and install the latest available version of Cordova CLI:
  13. npm install -g cordova

  14. Add needed platform using cordova platform add android.
  15. Build using cordova build android.
  16. Add the required Cordova plugin using cordova plugin add <plugin>.
  17. Create a javascript file to include required functionality from imported plugin. You must export all the functions via a single variable. Your javascript file looks similar to the example shown in the image below:
  18. Add the javascript file as external script in an UI model. You can use all the available features from javascript file. For example, as shown in the above image invoking contacts.search allows to call the search function.
  19. As these features work only on mobile devices, it is recommended to check the device using:
    • navigator.userAgent.toLowerCase().match(/android.*applewebkit(?=.*version)/);
    • navigator.userAgent.toLowerCase().match(/\(ip.*applewebkit(?!.*(version|crios))/);
  20. Test your application for the native features using ASG-Studio mobile app and fix the issues if you find any.