Deploying mobile apps / Deploying mobile apps on Android devices |
Genero provides a command-line tool to create applications for Android devices.
The GMA buildtool and the GMA binary archive must be installed.
The GMA buildtool and GMA binary archive are provided in the GMA distribution archive (fjs-gma-*.zip).
gmabuildtool updatesdk --android-sdk /use/local/32bits/android-sdk/r22.6.2
The Android SDK installation directory is required for the SDK update, and is found in ANDROID_HOME environment variable, or with the --android-sdk option.
gmabuildtool updatesdk --proxy-host amadeus --proxy-port 3232 ...
gmabuildtool updatesdk --no-install-extras ...
The gmabuildtool build ... command creates the APK from a set of files, and according to the options passed as parameter.
gmabuildtool build ... build options ...
Once the APK file is created, use the gmabuildtool test --test-apk command to install the app on the Android device plugged to the computer, and start the app automatically.
gmabuildtool test --test-apk path-to-the-apk-file
For a complete description of command options, see gmabuildtool.
The build process is optimized to avoid a complete APK rebuild every time you invoke the GMA buildtool: When application program file changes are detected, the GMA buildtool will create archive files that can be reused in the next build if no changes are detected. However, files used for the optimized build might be corrupted, for example in case of user interruption or graddle build failure.
In this situation, you can use the --clean option of the gmabuildtool build ... command, to cleanup the scaffold build directory, and continue with a fresh build:
gmabuildtool build --clean ... build options ...
$ cat myoptions.txt --build-output-apk-name MyApp --build-app-name MyApp --build-app-package-name com.example.myapp ... $ gmabuildtool --input-options ./myoptions.txt
In order to build an APK that can be deployed on the market (Google Play), you need to sign your Android app.
First, you need to generate a keystore file with the keytool Android utility.
The keystore file and keystore alias will be used by the gmabuildtool to sign the APK with the jarsigner utility. These signing credentials are passed to the buildtool with the --build-jarsigner-keystore and --build-jarsigner-alias options.
For more details, see manual Android application signing.
For convenience, the buildtool supports a default directory structure to find all files required to build the APK:
top-dir | |-- main.42m and other program files, as described in Directory structure for GMA apps | |-- gma | |-- project | | ... | |-- temp | | ... | |-- ic_app_hdpi.png | |-- ic_app_mdpi.png | |-- ic_app_xhdpi.png | |-- ic_app_xxhdpi.png | | ...
In order to use a device feature such as the camera, an Android app must be created by specifying the corresponding Android permissions. Furthermore, Android distinguishes "normal" and "dangerous" permissions. While both type of permissions just need to be specified when building the app, "dangerous" permissions require a user validation: A popup dialog will appear to let the user confirm that the dangerous feature can be accessed. Before Android 6, dangerous permissions defined by the app were asked at app installation. Starting with Android 6, dangerous permissions must be asked by the app code on demand.
Android permissions required for the built-in front calls are automatically set by GMA, which ask automatically user confirmation if the permission is dangerous. For example, if the app code makes a chooseContact front call, the GMA will automatically ask the user for the Android permission to access the contacts database, and set the corresponding permission on confirmation. When building your app, there is no need to specify permissions required for built-in front calls.
Other permissions (not involved by built-in front calls) need to be defined when building the app, and "dangerous" permissions need to be asked to the user when needed. In order to ask the user for a given permission, the app must use the askForPermission front call.
Android permissions can be specified with the --build-app-permissions option of the gmabuildtool. Define the list of permissions as a single argument, by using the comma as separator.
gmabuildtool build \ ... --build-app-permissions android.permission.READ_CALENDAR,... \ ...
Android permissions listed below are defined by default by GMA and therefore do not need to be specified when building your app. For "dangerous" permissions, the GMA will automatically ask the user to access the feature, when corresponding front call is performed:
Other permissions required by the app but not listed here need to be specified when building your app, and if the permission enters in the "dangerous" category, the app code must issue an askForPermission front call before using the feature. For a complete list of Android permissions, see Android's Manifest permissions.
The value provided to the --build-app-colors option must be a comma-separated list of four hexadecimal RGB colors.
gmabuildtool build \ ... --build-app-colors "#F44336,#B71C1C,#EF9A9A,#FFFFFF" \ ...
For more details about Android color shemes, see Android Colors
Android apps can be generated in a debug or release version. Release version are prepared for distribution on Google Play, while debug versions are used in development. In debug mode, the app installed on the device will listen on the debug TCP port to allow fgldb -m connections.
gmabuildtool build \ --build-mode debug \ ...
By default the app is build in release mode.
$ cd top-dir $ gmabuildtool build \ --android-sdk /home/mike/android/sdk \ --build-project /home/mike/work/example/scaffold_project \ --build-apk-outputs /home/mike/work/example/outputs \ --build-output-apk-name MyApp \ --build-app-name MyApp \ --build-app-package-name com.example.myapp \ --build-app-version-code 1002 \ --build-app-version-name "10.02" \ --build-jarsigner-alias android_alias \ --build-jarsigner-keystore /home/mike/work/example/sign/android.keystore \ --build-mode release \ --build-app-permissions android.permission.ACCESS_WIFI_STATE,android.permission.CALL_PHONE
The gmabuildtool build command supports APK creation for applications using GMA custom extensions written in Java.
Before building the APK package, create the custom GMA binary archive with your extensions, as described in Packaging custom Java extensions for GMA.
$ gmabuildtool build ... --build-project /home/mike/android_project/mycustgma ...
There must be only one Android device connected or running Android emulator.
$ gmabuildtool test \ --test-apk /home/mike/work/example/outputs/MyApp-arm-debug.apk