Error dispatching input event - ArrayIndexOutOfBounds from touch input
<p>I'm getting this error on my app and I cannot figure out why it's happening. Nothing is coming up on Google </p>

<pre><code>Thread [&lt;1&gt; main] (Suspended (exception ArrayIndexOutOfBoundsException))    
ViewRootImpl.deliverInputEvent(ViewRootImpl$QueuedInputEvent) line: 3173    
ViewRootImpl.doProcessInputEvents() line: 4292  
ViewRootImpl.enqueueInputEvent(InputEvent, InputEventReceiver, int, boolean) line: 4271 
ViewRootImpl$WindowInputEventReceiver.onInputEvent(InputEvent) line: 4363   
ViewRootImpl$WindowInputEventReceiver(InputEventReceiver).dispatchInputEvent(int, InputEvent) line: 179 
MessageQueue.nativePollOnce(int, int) line: not available [native method]   
MessageQueue.next() line: 125   
Looper.loop() line: 124 
ActivityThread.main(String[]) line: 5041    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 511  
ZygoteInit$MethodAndArgsCaller.run() line: 793  
ZygoteInit.main(String[]) line: 560 
NativeStart.main(String[]) line: not available [native method]  
</code></pre>

<p>My code:</p>

<pre><code>@Override
public boolean onTouchEvent(MotionEvent event) {
    if(event.getAction() == MotionEvent.ACTION_UP) {
        if(mDelegate != null) {


            int size = this.getWidth() / 3; // Board should remain a square

            // Get the row and column that was tapped based on the relative tap position
            int pointerX = (int)Math.floor((event.getX()) / size);
            int pointerY = (int)Math.floor((event.getY()) / size);


            Log.i("info", "Pointer x:"+pointerX+" y:"+pointerY);

            int index = (pointerY * 3) + pointerX;

            if(index &gt;= 0 &amp;&amp; index &lt; 9)             
                mDelegate.onSelectTile(index);
        }
    }

    return true;
}
@Override
public void onSelectTile(int index) {
    // TODO Auto-generated method stub
    Log.i("info", "Selected tile at index: "+index);

    if(mGameBoard[index] != 0)
        return;
    //mGameBoard.playMove(TURN.TURN_X, index);

    if(mTurn == Turn.PLAYER_1) {
        mGameBoard[index] = 1;
        mTurn = Turn.PLAYER_2;
        checkWinningConditions();
        mGameBoardView.invalidate();
        mTurns++;
    } else {
        mGameBoard[index] = 2;
        mTurn = Turn.PLAYER_1;
        checkWinningConditions();
        mGameBoardView.invalidate();
        mTurns++;
    }
}

private void checkWinningConditions() {

     // Horizontal victory
     for(int i = 0; i &lt; 4; i++) {
         if(mGameBoard[i] != 0 &amp;&amp; mGameBoard[i] == mGameBoard[i+1] &amp;&amp; mGameBoard[i] == mGameBoard[i+2]) {
             if(mGameBoard[i] == 1) {
                 addPlayer1Score();                  
             } else {
                 addPlayer2Score();                  
             }
             resetBoard();
             return;
         }
     }

     // Vertical victory
     for(int i = 0; i &lt; 4; i++) {
         if(mGameBoard[i] != 0 &amp;&amp; mGameBoard[i] == mGameBoard[i+3] &amp;&amp; mGameBoard[i] == mGameBoard[i+6]) {
             if(mGameBoard[i] == 1) {
                 addPlayer1Score();                  
             } else {
                 addPlayer2Score();                  
             }
             resetBoard();
             return;
         }
     }

     // Diagnal
     if(mGameBoard[4] != 0 &amp;&amp; mGameBoard[0] == mGameBoard[4] &amp;&amp; mGameBoard[0] == mGameBoard[8]) {
         if(mGameBoard[4] == 1) {
             addPlayer1Score();                  
         } else {
             addPlayer2Score();                  
         }
         resetBoard();
         return;
     }

     if(mGameBoard[4] != 0 &amp;&amp; mGameBoard[6] == mGameBoard[4] &amp;&amp; mGameBoard[2] == mGameBoard[4]) {
         if(mGameBoard[4] == 1) {
             addPlayer1Score();                  
         } else {
             addPlayer2Score();                  
         }
         resetBoard();
         return;
     }

     if(mTurns == 9) {
         // NO WINNER
         resetBoard();
     }

}
</code></pre>
