The purpose of this article is to help you set up Oxygene ready to develop Android applications. It assumes you have already installed Oxygene, but will walk you through installing the Java and Android SDKs, as well as setting up a virtual Android device and configuring your physical device for development. If you have already been developing for Android using another platform or have already set these things up independently, you do not need to read this article.
Android is an operating system for devices such as mobile telephones and tablet computers developed by the Open Handset Alliance led by Google. Application development is focused on targeting the specialized Dalvik Virtual Machine (VM), which is a mobile-optimized VM similar to the Java VM. Oxygene ships with templates for creating Android projects, and produces both native Java JAR files and the Android APK file necessary for deployment to an Android device.
The Pre-Flight Check
Each time you create an Android project with Oxygene, it will do a ‘pre-flight check’ to ensure that it can locate the things it needs, notably the JDK and the Android SDK.
If you’ve installed them into custom locations and it fails to find them, this gives you an opportunity to specify the installation folders by selecting the “Manually Specify The JDK Path” link from the dialog.
Oxygene requires version 6.0 or later of the Java Development Kit (JDK) to be installed. For Windows, we recommend installing the “x86″/”i586” release of version 7 JDK.
If you have not yet installed the JDK, you can download it from here.
Installing the JDK simply involves downloading the installer and running it, accepting all the defaults.
Once the JDK is installed, click Retest on the Pre-Flight Check dialog. If all has gone well, the dialog should change to report that the Android SDK is missing.
To create Android applications, Oxygene requires the Android SDK to be installed, in addition to the JDK.
If the JDK is installed, but not the Android SDK, the Oxygene pre-flight check will report this.
Download The Android SDK
The Android SDK can be downloaded here.
For Windows, we recommend using the .exe installer available under the “SDK Tools Only” section that is displayed when you expand the “Download for Other Platforms” area of the SDK download page , as it will automatically register the Android SDK with the system so that Oxygene can find it.
NOTE: If you download the .zip version of the SDK and manually extract it, you will need to manually configure the path to the Android SDK in the IDE options, as described further down on this page.
NOTE: If the Android SDK installer complains that the JDK cannot be found, that may be because you have the x64 version of the JDK installed (see above). Simply install the x86 (i.e. 32-bit) as well to solve this problem.
Once you have downloaded the Android SDK Installer, run it and accept all the defaults.
After installing the Android SDK, setup will automatically offer to launch the Android SDK Manager. Leave this checked.
The SDK Manager
In the SDK Manager, check to install the “Android SDK Platform-tools” and at least one API version (usually the newest) and click “Install Packages” to install.
In the subsequent dialog you will need to accept any licenses that apply and press “Install” again.
You should periodically run the SDK Manager to check for any updates to the tools and platforms.
Android Virtual Devices
When the tools and platforms are all installed, you might want to create an Android emulator, also known as an Android Virtual Device or AVD. This will allow you to test your application, in case you don’t have an actual device (or don’t want to use your device for development).
AVD’s are created from the Android Virtual Device Manager, which is accessible from either the SDK Manager by choosing Tools – Manage AVDs or by starting the AVD Manager program directly or from the Oxygene Visual Studio tool bar.
The AVD Manager
The first time you launch the AVD Manager there will be no configured AVD’s.
Create an AVD
To create a new AVD, click the “New” button. You will need to give the emulator a name. The AVD manager is pretty strict about what characters you can use in an AVD name, but will warn you when you use invalid characters.
Define a Device
The quickest way to set up an AVD is to emulate an actual device the DVD Manager already knows about. If you select the Device drop down, it will offer you a number of different Google devices it can emulate along with a set of generic devices.
If one of these predefined devices match the type of device you are targeting, then simply select it from the list.
If none of the devices in the list match the device you wish to target, you can set up all the fields in the AVD manager manually. For a full list of settings check out the AVD Hardware Options Documentation.
Select an API
You will also need to select the API level for the Target field. You can choose any installed API level, for example Android 4.4 – API Level 19.
When you choose a predefined device it will set the RAM setting for the AVD to match the actual device. In practice, this number may be too high to properly emulate and you could get a warning.
In this case, you will probably need to adjust the RAM setting to something more appropriate. (What’s appropriate will depend on the amount of memory in your development machine.)
Save The Device
Once the AVD is defined, click OK to save it. You will be shown a dialog confirming all the settings that will be used to create the AVD.
On clicking OK, the new AVD should now appear in the list of available AVD’s. If the AVD seems to be fully configured correctly, it will have a tick next to it in the list.
Test The Device
Once you have created an AVD, you can run it by selecting it in the list and clicking the “Start” button.
You will be presented with some launch options where you can simply click OK unless you need to change something.
The AVD will then begin to start.
After a few seconds, a blank emulator screen will appear. From this point, depending on the spec of your development machine, it could take several minutes for your device to appear in the emulator.
Testing Your AVD Setup
Now you are ready to test your setup. Leave the device running. From within Oxygene, start a new Android Application Project.
This will create a very simple Android Template Application. Click the “Start” button on the Visual Studio tool bar and Oxygene will build your project and deploy it to the emulator where you should be able to see it running.
Setting Up An Actual Device
AVD’s are great for testing your application on devices you don’t own. If you do however own a device, you can test your application right on the device itself. In many ways this is preferable to using an AVD, as you get to see exactly how it will run and perform.
Enable USB debugging on your device
Before you can debug an Android application on your device, you need to enable it for USB debugging.
On Android 4.0 and newer, you need to go into Developer Options and turn it on.
**NOTE: **On Android 4.2 and newer, Developer options are hidden by default. To make them available, go to Settings > About phone or Settings > About Tablet and tap Build Number seven times.
Once turned on (if necessary) you can find Developer options in Settings > Developer options.
If your device is running Android 3.2 or older, you can find the Developer options under Settings > Applications > Development.
Install USB Drivers For the Device
In order to connect to an Android device to test your applications, you need to install the appropriate USB driver. This page on the Android Developers website provides links to the web sites for several original equipment manufacturers (OEMs), where you can download the appropriate USB driver for your device. However, this list is not exhaustive for all available Android-powered devices. The page also gives information on how to install the driver once you have it.
Running Your App On The Device
Once the USB driver is installed for your device, make sure the device is connected to your machine. From Oxygene you can then choose to debug your application on your device by selecting your device from the Crossbox area of the Visual Studio tool bar.
The first time you run your application from within Oxygene on your device, a dialog will appear asking for permission.
You Are Ready To Go
That’s it. You are now set up and ready to begin developing Android applications using Oxygene.