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:
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:
Just select the appropriate link for your OS and you will be presented with an archive with the relevant files.
Configuring the Tools
- 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.
- When you have extracted the package, extract the Android NDK package into the same directory.
- Go into the eclipse folder and run the eclipse executable.
- Eclipse asks for a workspace. The workspace is where your projects and applications reside. Select a suitable location and select OK.
- 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:
- Click on Window -> Preferences.
- In the window that opens, select Android from the drop down list and then select NDK.
- Browse through your directory structure until you come to the NDK folder you extracted previously.
- 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:
- Open Settings and then Developer Options.
- Activate the USB debugging option.
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.
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:
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:
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:
- Open eclipse the same way as done previously and click File -> Import.
- From the list select Android -> Existing Android Code into Workspace.
- 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:
- Navigate to the directory where you installed the NDK.
- Inside that folder there is a samples folder. Navigate to the hello-gl2 folder in this directory and then select OK.
- Return to the import projects page and there is now a project in the projects table.
- 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:
- Right click on your project in the Package Explorer and then select Android Tools.
- Select Add Native Support.
- 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:
- Click on the Window and then go to Preferences.
- From the menu that appears select the Android and the Build options.
- 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.
- 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
- 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.
- 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.