Of course, you can create an OpenGL ES 2.0 shader in an Android application. The main thing is to use the correct OpenGL ES 2.0 context. I did something similar in my application, namely, initialized the EGL context in my own part, and then created (and used) shaders only in my own code. Based on what I was able to do, I assume that what you want to do is also quite possible.
Since I had an entry point to Java code (did not use the NativeAcvity mechanism), I also had to pass my own window handle ( EGLNativeWindowType ) from java to C ++ to create an EGL surface in my own code. However, since you just want to modify the NativeActivity example, you can use engine->app->window to create an EGL surface, as shown in the NativeActivity main.c example.
OK, how to create the correct OpenGL ES 2.0 context in native code? I just made two changes to the main.c file in the NativeActivity sample and checked its operation.
First, the following EGL attributes were used.
const EGLint attribs[] = { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
in eglChooseConfig(display, attribs, &config, 1, &numConfigs); .
Secondly, later in context creation it is used
const EGLint attrib_list [] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
in context = eglCreateContext(display, config, NULL, attrib_list);
I left the rest of the code unchanged. I printed some information to make sure OpenGL ES 2.0 is used:
I/native-activity( 955): Details: [Version: OpenGL ES 2.0 1403843], [Vendor: Qualcomm], [Renderer: Adreno 205], [Extensions: GL_AMD_compressed_3DC_texture GL_AMD_compressed_ATC_texture ... ]
Hope this helps!