3 Setting Up Development Tools for the Android Platform

This chapter provides information on setting up and configuring development tools for the Android platform. Install the Android SDK and the emulator accelerator so that you can deploy the MAF applications developed in JDeveloper to a configured Android device or emulator.

This chapter includes the following sections:

Installing the Android SDK

Install the Android SDK to deploy a MAF application to Android devices.

Android Studio, Google’s IDE for Android development, includes the Android SDK in its installation and provides wizard options that simplify the management of the SDK platforms and tools that you need.

Install Android Studio, and the Android SDK that it includes, by downloading the installation file from https://developer.android.com/studio/index.html. The Android Developer’s website provides installation instructions for Windows, Mac, and Linux. See https://developer.android.com/studio/install.html.

The Android SDK provides:
  • Tools that build and package your application into an .APK file (the file type that installs applications on Android devices)

  • An emulator to create Android Virtual Devices (AVD) where you can test your application if you do not have access to a physical Android device

  • An OEM USB driver to connect your development machine to a physical Android device through a USB cable if you do have a device (enables you to deploy an application from your development machine to the Android device)

Specifying the Android Settings in MAF

Configure the Android-specific settings, such as Android SDK, build tools location, and signing information to package and deploy applications to the Android platform.

For the Android platform, you can specify preferences using the GUI or command line.

Using the GUI

To configure your environment for the Android platform:

  1. Ensure the Android SDK is installed.
  2. In JDeveloper, click Tools, and then click Preferences.
  3. In the Preferences dialog, click Mobile Application Framework , and then click Android Platform.
  4. Specify the location of the Android SDK on your computer.
  5. Specify the location of the Android build tools on your computer.
  6. Provide information on the signing credentials.
    For more information about creating a key and keystore, see How to Sign a MAF Application that You Deploy to the Android Platform in Developing Mobile Applications with Oracle Mobile Application Framework.

    Figure 3-1 Configuring Platform Preferences for Android

    Description of Figure 3-1 follows
    Description of "Figure 3-1 Configuring Platform Preferences for Android"

Using the Command Line

You can set MAF preferences required to develop MAF applications, such as the Android SDK location, by specifying startup parameters when you start JDeveloper.

To launch JDeveloper from the command line with startup parameters, use the -J-D options. All strings must be enclosed in double-quotes, as shown in the examples.

The following example shows how to override the location of the Android SDK:

jdeveloper.exe -J-Doracle.adfmf.framework.dt.preferences.PlatformSDKsPrefs.androidPlatformDir="C:\<my_Android_SDK_path>"

These are the startup parameters you can use to set Android preferences from the command line:

  • oracle.adfmf.framework.dt.preferences.PlatformSDKsPrefs.androidSdkDir

  • oracle.adfmf.framework.dt.preferences.PlatformSDKsPrefs.androidBuildToolsDir

  • oracle.adfmf.framework.dt.preferences.PlatformSDKsPrefs.androidReleaseSigningKeystorePath

  • oracle.adfmf.framework.dt.preferences.PlatformSDKsPrefs.androidReleaseSigningKeystorePath

Installing an Emulator Accelerator

You can accelerate the performance of the emulator that renders AVDs by installing an emulator accelerator.

Once installed, the emulator accelerator speeds up the performance of the emulator and the AVDs that it emulates by allocating additional resources from your development machine. You specify the amount during installation of the accelerator. Once installed, the accelerator appears in the SDK Tools list of the SDK Manager that you can launch from Android Studio, as shown in the following image. The Intel x86 Emulator Accelerator (HAXM) is one type of emulator accelerator that is available.

Figure 3-2 Install Emulator Accelerator

Description of Figure 3-2 follows
Description of "Figure 3-2 Install Emulator Accelerator"

Make sure that the update site for the emulator accelerator that you want to download is selected in the SDK Update Sites tab shown in the previous image. Once downloaded, execute the installer. See https://developer.android.com/studio/run/emulator-acceleration.html#accel-vm.

Creating an Android Virtual Device

An Android Virtual Device (AVD) replicates an Android device on your development computer. It is a useful option for testing, especially if you only have access to one or a limited range of physical Android devices.

The AVD Manager that you launch from Android Studio by clicking Tools then Android, and then AVD Manager has a range of ready-to-use virtual devices. It includes most of those devices developed by Google itself, such as the Nexus and Pixel XL range. Google maintains documentation describing how to manage AVDs (see https://developer.android.com/studio/run/managing-avds.html).

Other Android device vendors, such as Samsung, provide specifications on their websites that you can use to create the AVD yourself.

To create an AVD:

  1. In Android Studio, launch the Android Virtual Device Manager by selecting Tools, then Android, and then AVD Manager.

  2. In the Your Virtual Devices screen, click Create Virtual Device.

  3. In the Select Hardware screen, select a phone device, such as Pixel, and then click Next.

  4. In the System Image screen, click Download for one of the recommended system images. Agree to the terms to complete the download.

  5. After the download completes, select the system image from the list and click Next.

  6. On the next screen, leave all the configuration settings unchanged and click Finish.

  7. In the Your Virtual Devices screen, select the device you just created and click Launch this AVD in the emulator.

Setting Up Your Android Device to Install an App from Your Development Machine

You can install your app directly from your development machine to your Android device by configuring the Android device and connecting it to your development machine using a USB cable.

To set up your Android device:

  1. Connect your device to your development machine with a USB cable.

    If you are developing on Windows, you might need to install the appropriate USB driver for your device. For help installing drivers, see the OEM USB Drivers document.

  2. Enable USB debugging on your device by going to Settings > Developer options.

    Note:

    Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.

Testing the Android Environment Setup

Deploy a MAF sample application to test that you set up your Android environment successfully.

You can test your environment setup as follows:
  1. In JDeveloper, open the HelloWorld sample application.

    See MAF Sample Applications in Developing Mobile Applications with Oracle Mobile Application Framework.

  2. Select Application then Deploy from the main menu.

    See Deploying Mobile Applications in Developing Mobile Applications with Oracle Mobile Application Framework.

  3. From the dropdown menu, select the deployment profile for the Android platform.
  4. Select Deploy application to emulator in the Deploy dialog.
    Using an Android-powered device emulator to test the environment setup is preferable because it does not require signing of the application. Ensure that the emulator is running before you start the deployment.

    Figure 3-3 Selecting Deployment Action for Android

    Description of Figure 3-3 follows
    Description of "Figure 3-3 Selecting Deployment Action for Android"
  5. Click Next on the Deploy dialog to verify the Summary page, and then click Finish.

See Deploying Mobile Applications in Developing Mobile Applications with Oracle Mobile Application Framework.

After a successful deployment (which might take a few minutes), the device to which you had deployed the application displays the launch screen of the HelloWorld application, and then displays the default application feature.