title: error when creating program and trying to get attribute Location | Opengl ES 2.0 Android
body: <p>I am trying to draw a textured square on the screen, but whenever I try to use <code>glGetAttribLocation</code> it gives me a <code>runtimeException</code> and <code>glError 1280</code>. I have no clue why when tested on a new end device, such as Samsung Galaxy S 3, no error was found. But on the rest of my testing devices this error kept appearing. </p>
  
  <p>Here is my Vertex Shader:</p>
  
  <pre><code>uniform mat4 uMVPMatrix;
  attribute vec4 aPosition;     
  attribute vec2 aTextureCoord;
  varying vec2 vTextureCoord;
  void main() {
  
  gl_Position = uMVPMatrix * aPosition;
  vTextureCoord = aTextureCoord;
  
  }
  </code></pre>
  
  <p>and my Fragment Shader:</p>
  
  <pre><code>precision mediump float;
  varying vec2 vTextureCoord;
  uniform sampler2D sTexture;
  void main() {
  
   gl_FragColor = texture2D(sTexture, vTextureCoord);
  
  }
  </code></pre>
  
  <p>and this is where the error occurs:</p>
  
  <pre><code>    private void initProgram() {
      mProgram = createProgram(mVertexShader, mFragmentShader);
      if (mProgram == 0) {
          return;
      }
      maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
      checkGlError("glGetAttribLocation aPosition");
      if (maPositionHandle == -1) {
          throw new RuntimeException(
                  "Could not get attrib location for aPosition");
      }
      maTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord");
      checkGlError("glGetAttribLocation aTextureCoord");
      if (maTextureHandle == -1) {
          throw new RuntimeException(
                  "Could not get attrib location for aTextureCoord");
      }
  
      muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
      checkGlError("glGetUniformLocation uMVPMatrix");
      if (muMVPMatrixHandle == -1) {
          throw new RuntimeException(
                  "Could not get attrib location for uMVPMatrix");
      }
  
  }
  </code></pre>
  
  <p>when checking for GLError i get the following exceptions:</p>
  
  <pre><code>12-31 21:07:56.836: E/ChizEngine(27809): glGetAttribLocation aPosition: glError 1280
  12-31 21:07:56.856: W/dalvikvm(27809): threadid=9: thread exiting with uncaught exception (group=0x4001d560)
  12-31 21:07:56.856: E/AndroidRuntime(27809): FATAL EXCEPTION: GLThread 10
  12-31 21:07:56.856: E/AndroidRuntime(27809): java.lang.RuntimeException: glGetAttribLocation aPosition: glError 1280
  12-31 21:07:56.856: E/AndroidRuntime(27809):    at test.projects.ogc.util.GLHelper.checkGlError(GLHelper.java:13)
  12-31 21:07:56.856: E/AndroidRuntime(27809):    at test.projects.ogc.objects.GameObject.initProgram(GameObject.java:168)
  12-31 21:07:56.856: E/AndroidRuntime(27809):    at test.projects.ogc.objects.GameObject.Draw(GameObject.java:206)
  12-31 21:07:56.856: E/AndroidRuntime(27809):    at test.projects.ogc.util.ChizRenderer.drawObjects(ChizRenderer.java:110)
  12-31 21:07:56.856: E/AndroidRuntime(27809):    at test.projects.ogc.util.ChizRenderer.onDrawFrame(ChizRenderer.java:42)
  12-31 21:07:56.856: E/AndroidRuntime(27809):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
  12-31 21:07:56.856: E/AndroidRuntime(27809):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
  </code></pre>
  
  <p>It appears when I call <code>glGetAttribLocation</code>, any idea why? </p>
  
  <p>If any more information is needed, please tell me, I'm trying to figure it out for few hours by now with no success at all, also, its weird that I don't get any error AT ALL on the galaxy s 3</p>
  
  <p>BTW i call the <code>initProgram</code> function on the <code>onSurfaceCreated</code> function in my renderer.</p>
  
  <p>apparently the error was the <code>checkGLError</code> itself (code below), after removing every call of the function from the app it worked as its supposed to on every device i checked on!</p>
  
  <p><code>checkGLError</code> function:</p>
  
  <pre><code>    public static void checkGlError(String op) {
      int error;
      while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
          Log.e(TAG, op + ": glError " + error);
          throw new RuntimeException(op + ": glError " + error);
      }
  }
  </code></pre>
  
  <p>my hypothesis is that something in the function is made for a higher api which is not supported by the 2.3 android devices that the app was checked on and that's why it worked fine on a 4.1.3 android device.</p>
  
  <p>Should i just exclude the function from my app completely? </p>