1 JNI Example 2 3 This sample shows how to build a native code library, package it into an APK, and call it using JNI. 4 5 Prerequesites 6 7 You must install the Android SDK in order to build the Java APK. The Android SDK can be downloaded 8 from 9 10 http://code.google.com/android/download.html 11 12 Build Steps: 13 14 1) Create an Eclipse project to for the Java code. 15 16 Launch Eclipse 17 Choose File : New : Project... 18 Choose Android : Android Project 19 Choose Next 20 Enter "JNIExample" into the Project name: field. 21 Choose "Create project from existing source" 22 Click the Browse button and browse to the pndk/samplejni directory 23 24 Click Finish 25 26 2) Build the Eclipse Project 27 28 Select the JNIExample project in the Package Explorer 29 Make sure that the menu item Project:Build Automatically is not checked. 30 Choose Project:Build 31 32 The resulting apk file ends up in bin/full/JNIExample.apk 33 34 2) Build the shared library, insert the shared library into the APK file and resign the 35 shared library. 36 37 ANDROID_SDK_BASE=<directory where SDK is installed> make 38 39 Install the APK on the device: 40 41 adb install -r bin/full/JNIExample.apk 42 43 Once the application is installed, you can run it by tapping on the "JNI Example" icon. 44