This chapter includes the following sections:
Prepare the environment for application development by setting up Eclipse, platform-specific tools, and a mobile device.
Before developing a MAF application, you must set up your development environment by downloading, installing, and configuring various software components.
To set up a typical MAF development environment that consists of an IDE, mobile platform-specific tools, and, possibly, a mobile device, follow the steps described in Prerequisites for Developing MAF Applications.
For a complete list of supported versions of development and runtime tools, see Oracle Mobile Application Framework Certification Matrix by following the Certification Information link on the MAF documentation page at http://www.oracle.com/technetwork/developer-tools/maf/documentation/
.
You need to specify JDK 8's JRE as the default JRE for OEPE, as described in How to Specify JDK 8's JRE as the Default in OEPE.
See the following sections for platform-specific prerequisites if you plan to target one or both of the following platforms:
What You Need to Develop an Application for the iOS Platform
What You Need to Develop an Application for the Android Platform
What You Need to Develop an Application for the Universal Windows Platform
You do not need to install any additional tools for creating specific types of MAF application content (HTML, remote URL, or MAF AMX).
A Mac computer, OEPE, Xcode and iOS SDK, JDK 1.8, credentials, and an iOS-powered device are needed for to develop applications for the iOS platform.
Before you start creating a MAF application for iOS, ensure that you have the following available:
A computer running Mac OS X
OEPE (see Setting Up OEPE)
Xcode and iOS SDK (see How to Install Xcode and iOS SDK)
The most recent version of JDK 8
Before you start deploying your application to a development environment (see Getting Started with Mobile Application Development in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition)), decide whether you would like to use a mobile device or its simulator: if you are to use a simulator, see How to Set Up an iPhone or iPad Simulator; if your goal is to deploy to a mobile device, ensure that, in addition to the components included in the preceding list, you have the following available:
Various login credentials. See Deploying Mobile Applications in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition).
iOS-powered device. See How to Set Up an iPhone or iPad.
Besides a computer running an OS supported by MAF, you need OEPE, JDK 8, Android SDK with platform and build tools, credentials, and an Android-powered device to develop applications for the Android platform.
Before you start creating a MAF application for Android, ensure that you have the following available:
A computer running an operating system listed in the Desktop OS Requirements section of the Oracle Mobile Application Framework Certification Matrix that you access by following the Certification Information link on the MAF documentation page at http://www.oracle.com/technetwork/developer-tools/maf/documentation/
.
The most recent version of JDK 8
Android SDK with platform and build tools (see How to Install the Android SDK)
OEPE (see Installing Oracle Enterprise Pack for Eclipse.)
Before you start deploying your application to a development environment (see Getting Started with Mobile Application Development in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition)), decide whether you would like to use a mobile device or its emulator: if you are to use an emulator, see How to Set Up an Android Emulator; if your goal is to deploy to a mobile device, ensure that, in addition to the components included in the preceding list, you have the following available:
Various login credentials. See Deploying Mobile Applications in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition).
Android-powered device. See How to Set Up an Android-Powered Device.
A computer with x86 architecture running the Windows 10 operating system, JDK 8, Microsoft Visual Studio 2015, MSBuild 14.0, and OEPE are required to develop applications for Universal Windows Platform.
Before you start creating a MAF application for Universal Windows Platform, ensure that you have the following available:
A computer with x86 architecture running the Windows 10 operating system
The most recent version of JDK 8
Microsoft Visual Studio 2015 (Enterprise, Professional, or Community edition)
MSBuild 14.0 (automatically installed with Visual Studio 2015)
Visual Studio Tools for Universal Windows Apps (an optional component when installing Visual Studio 2015)
Visual Studio 2015 is available at: https://www.visualstudio.com/products/vs-2015-product-editions
OEPE (see Installing Oracle Enterprise Pack for Eclipse.)
For more information about setting up and configuring your development environment, see Setting Up Development Tools for the Universal Windows Platform.
Setting up OEPE to develop MAF applications requires you to:
Specify the JRE from JDK 8, as described in How to Specify JDK 8's JRE as the Default in OEPE.
Configure OEPE to target the platform(s) you want the MAF application to run on, as described in How to Configure the Development Environment for Target Platforms.
OEPE requires that JDK 8 be specified as the default JRE for application development. Use the procedure to specify the JRE of JDK 8 as the default in OEPE.
You must specify the JRE packaged with JDK 8 as the default JRE in OEPE so that OEPE adds this JRE to the build path of newly-created MAF applications.
To specify JRE of JDK 8 as the default in OEPE:
Before you start developing and deploying a MAF application, you may need to configure preferences for appropriate platforms.
OEPE must be provided with information to package and deploy an application to a target platform. Use the procedure to configure the environment for target platforms.
For successful packaging and deployment of your application to target platforms supported by MAF, OEPE must be provided with information such as the name of the platform and directories on your development computer that contain the platform-specific tools and data.
Before you begin:
Depending on your target platform, download and configure the appropriate software for your target platform:
Android SDK (see How to Install the Android SDK) or iOS SDK and Xcode (see How to Install Xcode and iOS SDK)
Visual Studio (see How to Install Visual Studio)
To configure your environment for target platforms:
Set up an iPhone, iPad, or simulators to which MAF applications can be deployed.
In addition to general-purpose tools listed in Prerequisites for Developing MAF Applications, you might want to set up an iPhone or iPad when getting ready for development of a MAF application for the iOS platform (see How to Set Up an iPhone or iPad).
Since iPhone and iPad simulators are included in the iOS SDK installation, you do not need to separately install them. See How to Set Up an iPhone or iPad Simulator.
Download Xcode, which includes the iOS SDK, and run it at least once to ensure that builds and deployments proceed smoothly.
You download Xcode from http://developer.apple.com/xcode/
. This download includes the iOS SDK.
After installing Xcode, you have to run it at least once and complete the Apple licensing and setup dialogs. If these steps are not performed, any build and deploy cycle from OEPE to Xcode or a device simulator fails with a "Return code 69" error.
Note:
Since older versions of Xcode are not available from the Mac App Store, in order to download them you must obtain an Apple ID from http://appleid.apple.com
, and then register this Apple ID with the Apple Developer Program to gain access to the Apple developer site at http://developer.apple.com
.
An iOS-powered device with a valid license, certificates, and distribution profile must be connected to your computer for deployment of an application to the device.
In your MAF application development and deployment, you can use either the iPhone, iPad, or their simulators (see How to Set Up an iPhone or iPad Simulator). If you are planning to use an actual iPhone or iPad, which is preferable for testing (see Testing MAF Applications in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition)), you need to connect it to your computer to establish a link between the two devices.
To deploy to an iOS-powered device, you need to have an iOS-powered device with a valid license, certificates, and distribution profiles. See Deploying Mobile Applications in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition).
Note:
Since Apple licensing terms and conditions may change, ensure that you understand them, comply with them, and stay up to date with any changes.
Configure the external network access to use iOS simulators included in XCode downloads for the deployment of MAF applications.
In your MAF application development and deployment, you can use either the iOS-powered device itself (see How to Set Up an iPhone or iPad) or its simulator. Deploying to a simulator is usually much faster than deploying to a device, and it also means that you do not have to sign the application first.
A simulator can be invoked automatically, without any additional setup.
Note:
Before attempting to deploy your application from OEPE to a device simulator, you must first run the simulator.
If you are planning to use web services in your application and you are behind a corporate firewall, you might need to configure the external network access. You do so by modifying the network settings in the System Preferences on your development computer. See Configuring the Browser Proxy Information in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition).
Using an operating system that is compatible with OEPE and the Android platform, configure the Android SDK if you want to deploy applications to Android devices or emulators.
In addition to the general-purpose tools listed in Prerequisites for Developing MAF Applications, you might want to set up an Android-powered device when getting ready for development of a MAF application for the Android platform (see How to Set Up an Android-Powered Device).
Since emulators are included in the Android SDK installation, you do not need to separately install them. However, you cannot use an emulator until you create its configuration (see How to Set Up an Android Emulator).
To develop for the Android platform, you can use any operating system that is supported by both OEPE and Android.
See Developer Tools of the Android Developers website at http://developer.android.com/tools/index.html
.
Use the procedure to download the Android SDK starter package from the Android Developers website and install it. Alternatively, install components separately to build applications for Android-powered devices.
Android SDK includes the development tools that you need to build applications for Android-powered devices. Since the Android SDK is modular, it allows you to download components separately depending on your target Android platform and your application requirements.
Before you begin:
Make sure that your environment meets the operating system, JDK version, and hardware requirements listed in System Requirements on the Android Developers website at http://developer.android.com/sdk/index.html
.
To install the Android SDK:
Follow the instructions on the Android Developers website to set up devices. Edit the android_winusb.inf
file with the correct values for the device to set up an Android-powered device for the deployment of MAF applications.
In your MAF application development and deployment, you can use either the Android device itself, which is preferable for testing Testing MAF Applications), or an emulator (see How to Set Up an Android Emulator).
For information on how to set up the Android-powered device, follow the instructions from Using Hardware Devices on the Android Developers website at http://developer.android.com/tools/device.html
.
Note:
You might experience issues when using USB connectivity for the device-based debugging. See Testing and Debugging MAF Applications in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition).
Your target Android-powered device might not be listed in the .inf
file of the USB device driver, resulting in the failure to install the Android Debug Bridge (ADB). You can eliminate this issue as follows:
[Google.NTx86]
and [Google.NTamd64]
sections of the android_winusb.inf
file.See Google USB Driver on the Android Developers website at http://developer.android.com/sdk/win-usb.html
.
Follow the instructions on the Android Developers website to create the Android Virtual Device. Review the configuration of the settings to ensure that it matches your requirements.
In your MAF application development and deployment, you can use either the Android device itself (see How to Set Up an Android-Powered Device) or its emulator. Deploying to an emulator is usually much faster than deploying to a device, and it also means that you do not have to sign the application first.
For information on how to create an emulator configuration called Android Virtual Device (AVD), follow the instructions from Managing Virtual Devices of the Android Developers website at http://developer.android.com/tools/devices/index.html
. When creating an AVD through the Create New Android Virtual Device dialog (see Managing AVDs with AVD Manager at http://developer.android.com/tools/devices/managing-avds.html
), review all the settings to ensure that configuration matches what you are planning to emulate. In particular, you should verify the following:
The Target field should define the desired Android platform level for proper emulation.
The CPU/ABI field should reflect the Intel Atom system image (see Configuring AVD for Intel HAXM).
The SD card field should be defined based on whether the application uploads files or files install themselves to the SD card.
Default settings for the Hardware field (see the Hardware Options table at http://developer.android.com/tools/devices/managing-avds.html#hardwareopts
) should be acceptable for a typical MAF application. For additional hardware capabilities you may want to use in your application, such as cameras or geolocation services, create new properties.
You need to create an AVD for each Android platform on which you are planning to test your application.
For information on how to use the emulator, see Using the Android Emulator on the Android Developers website at http://developer.android.com/tools/devices/emulator.html
.
Complete the basic setup of the Android emulator, and then configure the emulator state, SD card, network, and the network proxy.
After the basic Android emulator setup is complete, you may want to perform the following configurations:
Save the emulator state (see Saving the Emulator State)
Create, save, and reuse the SD card (see Creating, Saving, and Reusing the SD Card)
Configure the network (see Configuring the Network)
Configure the network proxy (see Configuring the Network Proxy)
Save the emulator state and reuse it to save load time. You can also save emulator state from the CLI.
You can reduce the load time of the emulator by saving the emulator state or reusing the saved state. To do so, you manipulate the avd
files or folders that are located in the C:\Users\
username
\.android\avd
directory (on a Windows computer). Each avd
folder contains several files, such as userdata.img
, userdata.qemu.img
, and cache.img
. You can copy the cache.img
file to the avd
folder of another emulator to use that state with another emulator.
Alternatively, you can use the command line to run relevant commands, such as, for example, -snapshot-list
, -no-snapstorage
, and so on. You can access these commands through emulator -help
command.
Caution:
When using this utility, keep in mind that in the process of loading, all contents of the system, including the user data and SD card images, will be overwritten with the contents they held when the snapshot was made. Unless saved in a different snapshot, any changes will be lost.
Follow the instructions on the Android Developers website to create, save, and reuse an SD card.
SD Card Emulation on the Android Developers website at http://developer.android.com/tools/devices/emulator.html#sdcard
lists reasons for creating, saving, and reusing the SD card. You can perform these operations by executing the following commands:
To create an SD card:
C:\android sdk directory\tools>mksdcard -l SD500M 500M C:\Android\sd500m.img
To list existing AVDs:
C:\android sdk directory\tools>android list avd
This produces a listing similar to the following:
Available Android Virtual Devices: Name: AVD_for_Nexus_S Device: Nexus S (Google) Path: C:\Users\username\.android\avd\AVD_for_Nexus_S.avd Target: Android 5.0.1 (API level 21) Tag/ABI: default/armeabi-v7a Skin: 480x800 ------------ Name: AndroidEmulator2 Device: Nexus S (Google) Path: C:\Users\username\.android\avd\AndroidEmulator2.avd Target: Android 5.0.1 (API level 21) Tag/ABI: default/armeabi-v7a Skin: 480x800 Sdcard: 500M
To start the AndroidEmulator2 with the SD card that has just been created:
C:\Android\android sdk directory\tools>emulator -avd AndroidEmulator2 -sdcard C:\Android\sd500m.img
To list the running Android emulator instances:
C:\Android\android sdk directory\platform-tools>adb devices
To copy a test image to the SD card (this requires the emulator to restart):
C:\Android\sdk\platform-tools>adb push test.png sdcard/Pictures 85 KB/s (1494 bytes in 0.017s)
See the Android Tools Help at http://developer.android.com/tools/help/index.html
.
An Android emulator requires access to the host computer so that applications can be deployed to the emulator.
From the Android emulator, you can access your host computer through the 10.0.2.2 IP address. To connect to the emulator from the host computer, you have to execute the adb
command from a command line on your development computer or from a script to set up the port forwarding.
To forward socket connections, execute
adb forward
local
remote
using the following forward specifications:
tcp:
port
localabstract:
unix domain socket name
localreserved:
unix domain socket name
localfilesystem:
unix domain socket name
dev:
character device name
jdwp:
process pid
(remote only)
For example, an arbitrary client can request connection to a server running on the emulator at port 55000 as follows:
adb -e forward tcp:8555 tcp:55000
In this example, from the host computer, the client would connect to localhost:8555
and communicate through that socket.
See Android Debug Bridge on in the Android Developers website at http://developer.android.com/tools/help/adb.html
.
A computer that is protected by a corporate firewall requires a proxy to connect to an emulator. Use the procedure to start the emulator, and to configure the network proxy.
If your development computer is behind a corporate firewall, you might need to configure a proxy by using one of the following techniques:
Execute this command to start the emulator and initiate its connection with the browser:
emulator -avd myavd -http-proxy myproxy
Start the emulator and then use its Settings utility as follows:
Select Wireless & Networks.
Select Mobile Networks, and then select Access Point Names.
Select the appropriate internet option.
Set the proxy, port, username, and password using the Edit access point list.
Install Intel HAXM so that Intel drivers quicken deployment to an emulator. Some versions of operating systems require the Intel Hotfix for the emulator to work with Intel HAXM.
The Intel Hardware Accelerated Execution Manager (Intel HAXM) is designed to accelerate the Android-powered device emulator by making use of Intel drivers.
The Intel HAXM is available for computers running Microsoft Windows, Mac OS X, and a separate kernel-based virtual machine option (KRM) for Linux. See http://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager
to access installation guides and detailed descriptions of system requirements for each operating system.
Regardless of which operating system your development computer is running on, it must have the following:
Version 17 or later of the Android SDK installed (see How to Install the Android SDK).
Intel processor with support for Intel VT-x, EM64T and Execute Disable (XD) Bit functionality at the BIOS level.
Note:
It may be necessary to edit your system BIOS to enable Intel VT-x support. To do this, restart your computer but do not let it boot normally: interrupt your boot process, then select the menu to edit your BIOS. Scroll through the BIOS selections until you see the entry for VT-x, then toggle it to select Enabled.
At least 1 GB of available RAM.
To download the Intel HAXM, either use the Android SDK Manager (see the Speeding Up the Android Emulator on Intel Architecture article available at http://software.intel.com/en-us/android/articles/speeding-up-the-android-emulator-on-intel-architecture
) or use the following Intel locations:
For Microsoft Windows: http://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager-end-user-license-agreement
To install the Intel HAXM, follow steps described in the Speeding Up the Android Emulator on Intel Architecture article available at http://software.intel.com/en-us/android/articles/speeding-up-the-android-emulator-on-intel-architecture
. Particularly important is to configure AVD (see Configuring AVD for Intel HAXM).
If your development computer is running either Microsoft Windows 8.n or later, or Mac OS X 10.9.n or later, you have to apply a Hotfix provided by Intel before using emulator with the Intel HAXM.
Note:
If you do not apply the Hotfix, your computer will freeze and you will lose your work.
To download the Hotfix, use the following locations:
For Microsoft Windows: http://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager-end-user-license-agreement-windows-hotfix
See the following:
Installation Guide and System Requirements - Windows at http://software.intel.com/en-us/android/articles/installation-instructions-for-intel-hardware-accelerated-execution-manager-windows
Installation Guide and System Requirements - Mac OS X at http://software.intel.com/en-us/android/articles/installation-instructions-for-intel-hardware-accelerated-execution-manager-mac-os-x
Installation Guide and System Requirements - Linux at http://software.intel.com/en-us/blogs/2012/03/12/how-to-start-intel-hardware-assisted-virtualization-hypervisor-on-linux-to-speed-up-intel-android-x86-gingerbread-emulator
Use the Android SDK Manager to install the Intel Atom processor x86 system image for the relevant Android API version. The image is required for an installed Intel HAXM to function.
When enabling the Intel HAXM, ensure that you download the Intel system image for the Android API level using the Android SDK Manager (see Figure 2-2). As described in the Speeding Up the Android Emulator on Intel Architecture article at http://software.intel.com/en-us/android/articles/speeding-up-the-android-emulator-on-intel-architecture
:
After you have installed the Android SDK, open the SDK Manager and then find the Intel HAXM in the extras section.
Select Intel x86 Emulator Accelerator (HAXM) and click Install packages.
Once you have installed the package, the status changes to Installed, which is not accurate. The SDK only copies the Intel HAXM executable on your computer; you have to manually install the executable.
Figure 2-3 Downloading Intel System Image in Android SDK Manager
To install the Intel HAXM executable, depending on your development platform search your hard drive for one of the following:
On Windows, search for IntelHaxm.exe
On Mac OS X, search for IntelHaxm.dmg
If you accepted default settings, the executable should be located at C:\Program Files\Android\android-sdk\extras\Intel\Hardware_Accelerated_Execution_Manager\IntelHaxm.exe
on Windows.
The Intel HAXM only functions in combination with one of the Intel Atom processor x86 system images, which are available for Android 2.3.3 (API 10), 4.0.3 (API 15), 4.1.2 (API 16), 4.2.2 (API 17). These system images can be installed exactly like the ARM-based images through the Android SDK Manager.
Figure 2-4 Installing Intel Atom System Image
To complete the process, use the AVD Manager to create a new virtual device that has hardware-accelerated emulation by selecting Intel Atom (x86) as the CPU/ABI, (see Figure 2-5).
Note:
This option appears in the list only if you have the Intel x86 system image installed.
Figure 2-5 Creating Accelerated AVD
Ensure that the development computer meets the installation requirements. Install the MAF extension and Visual Studio 2015, create and install the PFX file, and enable the Development Mode on the computer to set up a Windows 10 computer for application development.
To set up your development machine so that you can develop and deploy a MAF application to UWP:
Verify that your computer meets the requirements listed in What You Need to Develop an Application for the Universal Windows Platform.
Install Visual Studio from Microsoft. The Visual Studio download provides the Windows SDK that enables deployment of applications to the UWP. Select the Visual Studio edition that you require: Community, Professional, or Enterprise. All editions provide the required software to develop and deploy a MAF application to the UWP. Visit the Visual Studio Community product page for information about the eligibility criteria to use Visual Studio Community edition.
Create and install the PFX file as described in How to Create a PFX File for MAF Applications and How to Install a PFX File on Windows 10.
Enable Development Mode on the computer on which you intend to develop the application as described in How to Enable Developer Mode on Windows 10.
After completing these setup tasks, a MAF application can be deployed to the UWP. See Deploying a MAF Application to the Universal Windows Platform in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition).
Install Visual Studio 2015 to access the Microsoft tools that are needed to build applications for deployment to Universal Windows Platform. Use the procedure to install Visual Studio.
You download and install Visual Studio from Microsoft Visual Studio web page.
To install Visual Studio
For the following information, see Windows Software Development Kit (SDK) for Windows 10 at https://dev.windows.com/en-us/downloads/windows-10-sdk
.
What's in the kit
New APIs
New and updated tools
System requirements
Instructions to install and uninstall
Known issues
A Personal Information Exchange file is needed to sign Universal Windows Platform based MAF applications. Use the procedure to create a PFX file.
MAF applications based on UWP must be digitally signed before deployment. A PFX file is required to sign an application. A PFX file contains a public x509 certificate file (.cer
) and a private key file (.pvk
).
To create a PFX file:
Every Personal Information Exchange file on a computer must be manually installed in a certificate store if you want to use it for application signing. Use the procedure to install a PFX file in a certificate store.
Copy or install.
An operating system keeps certificates in an area called a certificate store. A Software Publisher Certificate (SPC), with its private and public keys, is used for application signing. SPC is stored in a Personal Information Exchange (.pfx) file. A PFX file has to be copied or installed to a certificate store.
Note:
The installation has to be completed once, manually, for every PFX file on a given computer.
To install a PFX file in a certificate store:
Enable Developer Mode on the Windows 10 computer so that you can side-load applications. Use the procedure to enable Developer Mode.
Enable Developer Mode to develop MAF applications on Windows 10.
If you want to develop and deploy MAF applications to the UWP you must enable Developer Mode on the Windows 10 computer that you use. Developer Mode is required for the following reasons:
Side-load, or install and run applications, from unofficial sources.
Run an application in debug mode.
To enable Developer Mode:
Select a sample application from the Samples folder of the MAF extension download, and deploy it either to an iOS-powered device simulator or an Android-powered device emulator to test the environment setup. Use the procedure to test the setup.
You can test your environment setup as follows:
See the Deploying Mobile Applications in Developing Mobile Applications with Oracle Mobile Application Framework (OEPE Edition).
After a successful deployment (which might take a few minutes), your iOS-powered device simulator or Android-powered device emulator will display the HelloWorld application icon that you have to activate to launch the application.