Introduction

This guide helps you get up and running with developing for your Mali GPU based platform running Android. It helps you to download and configure the tools so you can begin to develop apps for your platform. The guide will then talk you through importing a basic Android project, building it and then running the project on a your target platform. It is assumed you are either running Linux or Windows as your host platform.

Getting the appropriate Tools

You require a few tools for Android Development. Most of these are in one place.

Download the bundle option from:

http://developer.android.com/sdk/index.htmlADT

Your web browser should present you with a zip package to download. This package contains the following items:

  • Eclipse + ADT plugin
  • Android SDK Tools
  • Android Platform-tools
  • The Latest Android Platform
  • The Latest Android System Image for the Emulator

To use the full power of your Mali GPU you also need the Android NDK. You can download this from:

http://developer.android.com/tools/sdk/ndk/index.html

Just select the appropriate link for your OS and you will be presented with an archive with the relevant files.

Configuring the Tools
  1. Select a destination directory and extract the first package into it. If possible, ensure the whole path to this directory has no spaces. Some of the tools such as cygwin do not work correctly if there are spaces.
  2. When you have extracted the package, extract the Android NDK package into the same directory.
  3. Go into the eclipse folder and run the eclipse executable.
  4. Eclipse asks for a workspace. The workspace is where your projects and applications reside. Select a suitable location and select OK.
  5. Close the welcome screen and you are presented with what looks like a workspace.

Before you can begin to create applications you must link the SDK and the NDK together:

  1. Click on Window -> Preferences.
  2. In the window that opens, select Android from the drop down list and then select NDK.
  3. Browse through your directory structure until you come to the NDK folder you extracted previously.
  4. Select OK.

To put your application onto a real device you must install drivers. For this guide we use the Allwinner A13 tablet which use the default Android USB Drivers. If you are using a different device consult the manufacturer to find out what drivers you need to install. You must also turn on USB debugging on your device for this to work. Do this by:

  1. Open Settings and then Developer Options.
  2. Activate the USB debugging option.
For Windows

To install the standard USB drivers go into the Android SDK Bundle directory and click on the SDK Manager. From here you are given a list of options that you can install. Under the Extras section you can find the Google USB Driver. Install this and you can use your device with your computer.

For Linux

Your device should be found automatically by a Linux system but there are no permissions associated to it. To give your device the appropriate permissions edit the file:

/etc/udev/rules.d/51-android.rules

If this file does not exist, create it. Inside the file you must add a rule for each Android device you intend to use. For example, this is a sample rule created for the Allwinner platform:

SUBSYSTEM==”usb”,ATTR{idVendor}==”18d1”,ATTR{idProduct}==”0003”, MODE=”0600”,OWNER=”YOURUSERNAME

Replace YOURUSERNAME with your username on your system.

Getting a NDK Application onto your Device

To prove your setup is ready for developing real applications, get one of the sample applications provided by Google working:

  1. Open eclipse the same way as done previously and click File -> Import.
  2. From the list select Android -> Existing Android Code into Workspace.
  3. A new menu appears. On the Root Directory select browse.
Test Your Installation

To test the SDK and NDK at the same time, pick one of the NDK samples:

  1. Navigate to the directory where you installed the NDK.
  2. Inside that folder there is a samples folder. Navigate to the hello-gl2 folder in this directory and then select OK.
  3. Return to the import projects page and there is now a project in the projects table.
  4. Select Finish.

This is a native application so you must enable native support inside the application, so Eclipse can correctly handle the project being written in both Java and C. To enable native application support:

  1. Right click on your project in the Package Explorer and then select Android Tools.
  2. Select Add Native Support.
  3. This provides an option to change the name of your native library, ignore this and click Finish.

It is sometimes easier when developing to turn a few options off in Eclipse. The main two options are Build Automatically and Skip Packaging and Dexing. To disable Build Automatically, click on the project menu and then deselect Build Automatically. To disable the Skip packaging and indexing option:

  1. Click on the Window and then go to Preferences.
  2. From the menu that appears select the Android and the Build options.
  3. From the options presented uncheck Skip Packaging and Dexing until export or launch.

You are now ready to build your project. Right click on the project and then select Build.

Note: You might have to do this two or three times to generate all the required files the first time you build an application.

If you get the following warning:

APP_PLATFORM android-14 is larger than android:minSdkVersion 5.

Select AndroidManifest.xml in the Project Explorer and then single click on Uses Sdk and then change the Min SDK version from 5 to 14.

Running your New Application

There are two methods to place your application on your device. The easiest is to click the run button in eclipse and select Run As -> Android Application. This brings up a list of currently connected devices. Just pick the one you want to use and press OK.

The Application is sent to the device and then ran on the device.

Note: If you don’t have a device you can select an emulator that emulates a device for you.

The second method to place your application on your device is to use a program called ADB. This program is included in the bundle you downloaded earlier.

  1. Open up a terminal or command prompt and then navigate to the bin directory of the sample. This should be something like: cd c:\sdkBundleDirectory\android-ndk-r8d\samples\hello-gl2\bin
  2. Make sure your device is being picked up by Android. In the command prompt write the following: c:\sdkBundleDirectory\sdk\platform-tools\adb.exe devices. If your device isn’t listed, try reinstalling the drivers for your device.
  3. If your device is listed, run the following command for your application to appear on the device: c:\sdkBundleDirectory\sdk\platform-tools\adb.exe install GL2JNIActivity.apk
Where to go From Here

Now that you are setup and able to build one of the NDK samples the world is your oyster.

Download the Mali SDK from www.malideveloper.arm.com

The Mali SDK provides some more in-depth samples for you to use to deepen your understanding of graphics. Another good place to help you develop for Android is to take a look at the samples that are included in the NDK and the SDK with Android.