public static int compileShader(final int shaderType,final String shaderSource){
  int shaderHandle=GLES20.glCreateShader(shaderType);
  if (shaderHandle != 0) {
    GLES20.glShaderSource(shaderHandle,shaderSource);
    GLES20.glCompileShader(shaderHandle);
    final int[] compileStatus=new int[1];
    GLES20.glGetShaderiv(shaderHandle,GLES20.GL_COMPILE_STATUS,compileStatus,0);
    if (compileStatus[0] == 0) {
      Log.e(TAG,"Error compiling shader: " + GLES20.glGetShaderInfoLog(shaderHandle));
      GLES20.glDeleteShader(shaderHandle);
      shaderHandle=0;
    }
  }
  if (shaderHandle == 0) {
    throw new RuntimeException("Error creating shader.");
  }
  return shaderHandle;
}

public static int compileShader ( final int shaderType , final String shaderSource ) { int shaderHandle = GLES20 . glCreateShader ( shaderType ) ; if ( shaderHandle != 0 ) { GLES20 . glShaderSource ( shaderHandle , shaderSource ) ; GLES20 . glCompileShader ( shaderHandle ) ; final int [ ] compileStatus = new int [ 1 ] ; GLES20 . glGetShaderiv ( shaderHandle , GLES20 . GL_COMPILE_STATUS , compileStatus , 0 ) ; if ( compileStatus [ 0 ] == 0 ) { Log . e ( TAG , "Error compiling shader: " + GLES20 . glGetShaderInfoLog ( shaderHandle ) ) ; GLES20 . glDeleteShader ( shaderHandle ) ; shaderHandle = 0 ; } } if ( shaderHandle == 0 ) { throw new RuntimeException ( "Error creating shader." ) ; } return shaderHandle ; }
helper function to compile a shader .
