109
edits
Joel Reymont (talk | contribs) |
Joel Reymont (talk | contribs) |
||
| Line 10: | Line 10: | ||
= Android Notes = | = Android Notes = | ||
== Building and running the OpenGL ES NDK example == | |||
Here's how to build and run the san-angeles application from NDK 1.6. This program demonstrates how to use a GLSurfaceView from Java along with native OpenGL calls to perform frame rendering. | |||
<pre> | |||
cd /Volumes/android/mydroid/ | |||
. build/envsetup.sh | |||
including vendor/aosp/vendorsetup.sh | |||
lunch sdk-eng | |||
============================================ | |||
PLATFORM_VERSION_CODENAME=REL | |||
PLATFORM_VERSION=1.6 | |||
TARGET_PRODUCT=sdk | |||
TARGET_BUILD_VARIANT=eng | |||
TARGET_SIMULATOR=false | |||
TARGET_BUILD_TYPE=release | |||
TARGET_ARCH=arm | |||
HOST_ARCH=x86 | |||
HOST_OS=darwin | |||
HOST_BUILD_TYPE=release | |||
BUILD_ID=Donut | |||
============================================ | |||
</pre> | |||
First, we need to build the shared library of native code | |||
<pre> | |||
cd ~/work/android/android-ndk-1.6_r1/ | |||
build/host-setup.sh | |||
make APP=san-angeles | |||
Android NDK: Building for application 'san-angeles' | |||
Compile thumb : sanangeles <= apps/san-angeles/project/jni/importgl.c | |||
Compile thumb : sanangeles <= apps/san-angeles/project/jni/demo.c | |||
Compile thumb : sanangeles <= apps/san-angeles/project/jni/app-android.c | |||
SharedLibrary : libsanangeles.so | |||
Install : libsanangeles.so => apps/san-angeles/project/libs/armeabi | |||
</pre> | |||
Next, we need to make sure we can build the Java portion of the project | |||
<pre> | |||
android update project --path apps/san-angeles/project | |||
Updated local.properties | |||
File build.xml is too old and needs to be updated. | |||
Added file apps/san-angeles/project/build.xml | |||
</pre> | |||
Now, lets build the debug release of project | |||
<pre> | |||
cd apps/san-angeles/project/ | |||
ant debug | |||
Buildfile: build.xml | |||
[setup] Project Target: Android 1.6 | |||
[setup] API level: 4 | |||
dirs: | |||
[echo] Creating output directories if needed... | |||
resource-src: | |||
[echo] Generating R.java / Manifest.java from the resources... | |||
aidl: | |||
[echo] Compiling aidl files into Java classes... | |||
compile: | |||
[javac] Compiling 1 source file to /Users/joelr/Work/android/android-ndk-1.6_r1/apps/san-angeles/project/bin/classes | |||
dex: | |||
[echo] Converting compiled files and external libraries into bin/classes.dex... | |||
package-resources: | |||
[echo] Packaging resources | |||
[aaptexec] Creating full resource package... | |||
debug-sign: | |||
package: | |||
[apkbuilder] Creating .DemoActivity-debug-unaligned.apk and signing it with a debug key... | |||
[apkbuilder] Using keystore: /Users/joelr/.android/debug.keystore | |||
[apkbuilder] /Users/joelr/Work/android/android-ndk-1.6_r1/apps/san-angeles/project/bin/classes.dex => classes.dex | |||
[apkbuilder] /Users/joelr/Work/android/android-ndk-1.6_r1/apps/san-angeles/project/libs/armeabi/libsanangeles.so => lib/armeabi/libsanangeles.so | |||
debug: | |||
[echo] Running zip align on final apk... | |||
[echo] Debug Package: bin/.DemoActivity-debug.apk | |||
BUILD SUCCESSFUL | |||
Total time: 1 second | |||
</pre> | |||
Finally, let's install the app on the device | |||
<pre> | |||
adb install -r bin/.DemoActivity-debug.apk | |||
1107 KB/s (13707 bytes in 0.012s) | |||
pkg: /data/local/tmp/.DemoActivity-debug.apk | |||
Success | |||
</pre> | |||
To run the app click on the "tab" at the bottom of the Android emulator screen and then on the DemoActivity icon in the list of applications. Enjoy! | |||
== Drawing and input from native code == | == Drawing and input from native code == | ||
edits