android on intel course sdk/ndk environment · eclipse – hello jni in eclipse, create a new...

Post on 07-Jul-2020

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Android on Intel CourseSDK/NDK Environment

Paul Guermonprezwww.Intel-Software-Academic-Program.com

paul.guermonprez@intel.comIntel Software

2013-02-08

Goals and Prerequisites

Goals

Starting from a blank Ubuntu 12.04,we'll install and run simple apps for :

1. Android SDK (prepackaged ADT)

2. Android NDK (native development)

3. Intel Compiler and libraries for the NDK

4. Intel Graph Performance Analyzer

What you'll need

OS : We'll use Ubuntu 12.04 (but you can do the same on Windows, OSX, other linuxes)

Mobile : Not mandatory, but better : An Intel based android mobile device and USB cable, as we'll use debugging and performance monitoring on the mobile itself over USB.

Computer : A touch screen (from an Ultrabook touch) is interesting to test touch apps on your PC.

Java and Ubuntu packages

JDK6 :

sudo apt-get install openjdk-6-jdkjava -version

java version "1.6.0_24"

Packages :

sudo apt-get install ia32-libs # if running 64b

Virtualization support

Hardware : If the processor has Intel VT (virtualization) technology, the android emulation will go a LOT faster.If you have the vPro sticker, you have VT.

BIOS : enable virtualization support in the BIOS

OS :

sudo apt-get install cpu-checker qemu-kvmsudo adduser `id -un` kvm

# logoff, login

sudo modprobe kvm_intelsudo kvm-ok

INFO: /dev/kvm existsKVM acceleration can be used

Android SDK

Android SDK

Install the SDK :Download and unzip the “Android Developer Tools” from http://developer.android.com/sdk/index.html

Add to your PATH, example in your .bashrc file :export PATH=$PATH:~/adt_install_folder/sdk/toolsthen launch the command : android

Package selection :Pick the right API level for your target devices, and do not forget the Intel image (independently from your target device cpu).

See following screenshots.

SDK Package selection

SDK Package selection+ API 15 for Orange-Intel phone

SDK Hello World

Eclipse – New Project

Launch :./adt-bundle-linux-x86_64/eclipse/eclipse

Create new Android project :File > New > Android Application Project

Eclipse – Finish Hello World

Fill the name, project and package,then complete the wizard by clickingnext several times and finish.

You now have a simpleHello World app.

Eclipse – Android Virtual Device

To create an AVD :Window > Android VirtualDevice ManagerNew …

The screenshot showsthe details of an OrangeSanta Clara AVD :- 1024x600, front camera- Intel cpu- 1024Mo RAM- Use Host GPU

Close AVD Manager

Eclipse – Run Hello World

Right click on the project name (left menu)Run As > Android Application

Eclipse – Run in AVD

The AVD will be launched, the app will be compiled, packaged, transferred to the AVD and launched. You should see that :

You can create and launch a non Intel AVDto see the huge performance difference.

Eclipse – Run in Real Device

If you plug a real Android device with a USB cable, you can deploy on the device instead of the AVD :

Android NDK

Android NDK

Why : To build native apps (partially or totally native), you'll need to install the NDK.

How : Download the archive from and untar :http://developer.android.com/tools/sdk/ndk/

Add the ndk folder to your PATH,example in your .bashrc file :export PATH=$PATH:~/ndk_install_folder

Ubuntu : Install build tools :sudo apt-get install build-essential

Eclipse – Hello JNI

In eclipse, create a new project by importing the folder “samples/hello-jni” from the ndk folder.File > New > Project …Android > Android Project from Existing Code

Check “Copy projects into workspace”

Under command line in your project folder(in my case workspace/HelloJni),create the build.xml file with :android update project -p . -s

Eclipse – Build Hello JNI

Directory : Go to the project's jni folder.In my case, ~/workspace/HelloJni/jni/

Target : Create a file Application.mk with this line :APP_ABI := x86

Launch : ndk-buildGdbserver : [x86-4.6] libs/x86/gdbserverGdbsetup : libs/x86/gdb.setupCompile x86 : hello-jni <= hello-jni.cSharedLibrary : libhello-jni.soInstall : libhello-jni.so => libs/x86/libhello-jni.so

Check : launch : file ../libs/x86/libhello-jni.so../libs/x86/libhello-jni.so: ELF 32-bit LSB shared object,Intel 80386, version 1 (SYSV), dynamically linked, stripped

Note : 32bit binary, even on a 64bit build system.

Eclipse – Run Hello JNI

Run as > Android Application,and you should see :

License Creative Commons - By 3.0

You are free:

to Share — to copy, distribute and transmit the work

to Remix — to adapt the work

to make commercial use of the work

Under the following conditions:

Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

With the understanding that:

Waiver — Any of the above conditions can be waived if you get permission from the copyright holder.

Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license.

Other Rights — In no way are any of the following rights affected by the license:

Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; The author's moral rights; Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.

Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.

http://creativecommons.org/licenses/by/3.0/

top related