How to compile Android NDK samples (in Ubuntu Linux)

Assuming Android NDK is installed in /opt/android-ndk-r8e and Android SDK is in /opt/android-sdk-linux and that “ant” have been installed (via “apt-get install ant” in Ubuntu). Only the following four commands are needed for compiling the NDK samples and generating the APK for installation into Android devices:

/opt/android-ndk-r8e/ndk-build

ant clean

/opt/android-sdk-linux/tools/android update project --path . --target android-17

ant debug

and below are the output:

First is the EGL libraries of the sample:

Inside the directory /opt/android-ndk-r8e/samples/hello-gl2:

/opt/android-ndk-r8e/ndk-build ======> gives:

Compile++ thumb : gl2jni <= gl_code.cpp
StaticLibrary : libstdc++.a
SharedLibrary : libgl2jni.so
Install : libgl2jni.so => libs/armeabi/libgl2jni.so

and then is the compilation of the JAVA into APK:

/opt/android-sdk-linux/tools/android update project --path . --target android-17

Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using Activity name ‘GL2JNIActivity’.
If you wish to change it, edit the first line of build.xml.
Added file ./build.xml
Added file ./proguard-project.txt

ant debug

Buildfile: /opt/android-ndk-r8e/samples/hello-gl2/build.xml

XXXXX (lots of output truncated)

-build-setup:
[getbuildtools] Using latest Build Tools: 17.0.0
[echo] Resolving Build Target for GL2JNIActivity…
[gettarget] Project Target: Android 4.2.2
[gettarget] API level: 17
[echo] ———-
[echo] Creating output directories if needed…
[mkdir] Created dir: /opt/android-ndk-r8e/samples/hello-gl2/bin
[mkdir] Created dir: /opt/android-ndk-r8e/samples/hello-gl2/bin/res
[mkdir] Created dir: /opt/android-ndk-r8e/samples/hello-gl2/gen
[mkdir] Created dir: /opt/android-ndk-r8e/samples/hello-gl2/bin/classes

-obfuscate:

-dex:
[dex] input: /opt/android-ndk-r8e/samples/hello-gl2/bin/classes
[dex] Converting compiled files and external libraries into /opt/android-ndk-r8e/samples/hello-gl2/bin/classes.dex…

-crunch:
[crunch] Crunching PNG Files in source dir: /opt/android-ndk-r8e/samples/hello-gl2/res
[crunch] To destination dir: /opt/android-ndk-r8e/samples/h
[crunch] ello-gl2/bin/res
[crunch] Crunched 0 PNG files to update cache

-package-resources:
[aapt] Creating full resource package…

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating GL2JNIActivity-debug-unaligned.apk and signing it with a debug key…

-post-package:

-do-debug:
[zipalign] Running zip align on final apk…
[echo] Debug Package: /opt/android-ndk-r8e/samples/hello-gl2/bin/GL2JNIActivity-debug.apk
[propertyfile] Creating new property file: /opt/android-ndk-r8e/samples/hello-gl2/bin/build.prop
[propertyfile] Updating property file: /opt/android-ndk-r8e/samples/hello-gl2/bin/build.prop
[propertyfile] Updating property file: /opt/android-ndk-r8e/samples/hello-gl2/bin/build.prop
[propertyfile] Updating property file: /opt/android-ndk-r8e/samples/hello-gl2/bin/build.prop

And after installing and running it:

I/ActivityManager( 275): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.gl2jni/.GL2JNIActivity} from pid 392
W/WindowManager( 275): Failure taking screenshot for (246×410) to layer 21005
E/SurfaceFlinger( 36): ro.sf.lcd_density must be defined as a build property
D/dalvikvm( 900): Not late-enabling CheckJNI (already on)
I/ActivityManager( 275): Start proc com.android.gl2jni for activity com.android.gl2jni/.GL2JNIActivity: pid=900 uid=10049 gids={50049, 1028}
I/ActivityManager( 275): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.gl2jni/.GL2JNIActivity} from pid 392
I/dalvikvm( 900): Turning on JNI app bug workarounds for target SDK version 5…
E/Trace ( 900): error opening trace file: No such file or directory (2)
V/PhoneStatusBar( 335): setLightsOn(true)
E/SurfaceFlinger( 36): ro.sf.lcd_density must be defined as a build property
I/Choreographer( 275): Skipped 37 frames! The application may be doing too much work on its main thread.
E/SurfaceFlinger( 36): ro.sf.lcd_density must be defined as a build property
D/libEGL ( 900): Emulator without GPU support detected. Fallback to software renderer.
D/libEGL ( 900): loaded /system/lib/egl/libGLES_android.so
I/Choreographer( 900): Skipped 70 frames! The application may be doing too much work on its main thread.
W/dalvikvm( 900): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
E/AndroidRuntime( 900): FATAL EXCEPTION: GLThread 90
E/AndroidRuntime( 900): java.lang.IllegalArgumentException: No configs match configSpec
E/AndroidRuntime( 900): at com.android.gl2jni.GL2JNIView$ConfigChooser.chooseConfig(GL2JNIView.java:168)
E/AndroidRuntime( 900): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1024)
E/AndroidRuntime( 900): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1401)
E/AndroidRuntime( 900): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
D/gralloc_goldfish( 900): Emulator without GPU emulation detected.
W/ActivityManager( 275): Force finishing activity com.android.gl2jni/.GL2JNIActivity
W/WindowManager( 275): Failure taking screenshot for (246×410) to layer 21020
I/ActivityManager( 275): Displayed com.android.gl2jni/.GL2JNIActivity: +1s523ms
I/Choreographer( 392): Skipped 38 frames! The application may be doing too much work on its main thread.
I/Choreographer( 275): Skipped 43 frames! The application may be doing too much work on its main thread.
E/SurfaceFlinger( 36): ro.sf.lcd_density must be defined as a build property
E/SurfaceFlinger( 36): ro.sf.lcd_density must be defined as a build property
I/Process ( 900): Sending signal. PID: 900 SIG: 9
I/ActivityManager( 275): Process com.android.gl2jni (pid 900) has died.
W/InputMethodManagerService( 275): Got RemoteException sending setActive(false) notification to pid 900 uid 10049

moz screenshot

More debugging needed.

Advertisements

One response to this post.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: