Recently I started playing with the Android NDK. Looking at the included samples, I stumbled upon a native compilation problem (using the latest Android NDK Revision 8b):
compilation failed for hello-gl2 and san-angeles:
Compile++ thumb : gl2jni <= gl_code.cpp D:/Work/Apps/android-ndk/samples/hello-gl2//jni/gl_code.cpp:22:23: fatal error: GLES2/gl2.h: No such file or directory compilation terminated. make: *** [D:/Work/Apps/android-ndk/samples/hello-gl2//obj/local/armeabi/objs/gl 2jni/gl_code.o] Error 1
Searching around, I found others with the same problem, but no clear solution. However, the problem is quite simple: Google forgot to include the Application.mk file for these samples.
So to fix it, you need to create Application.mk, or copy an existing one from another sample. You will need to set the APP_PLATFORM inside it to the one used by the Java project. Check the AndroidManifest.xml file for each sample (ie.
Here’s my Application.mk for hello-gl2:
# The ARMv7 is significanly faster due to the use of the hardware FPU APP_ABI := armeabi armeabi-v7a APP_PLATFORM := android-5
For san-angeles it’s this:
# The ARMv7 is significanly faster due to the use of the hardware FPU APP_ABI := armeabi armeabi-v7a APP_PLATFORM := android-4
Please note that for OpenGL 1.x, the minimum platform is android-4; for OpenGL 2.x, it’s android-5.
UPDATE: I was testing the OpenGL samples, but it seems others fail as well:
native-audio (set android platform to android-9 – at least)
native-media (set android platform to android-14 – currently maximum included platform in NDK)
UPDATE 2: It seems there’s also an open issue at Google for this:
I updated it with the solution:
I hope this helps.