Im getting some weird error which crashing my android app. Its a quiz app. So when user answer 2/3 question correctly then click the next button this it crash. and show inde
In programming indexes often start at 0, so if you have 9 items, the highest index would be 8.
The actual error is being thrown from some code within the library you are using
org.anddev.andengine.entity.Entity.onManagedDrawChildren(Entity.java:1008)
It is likely that you are changing the list in a separate thread whilst the library is also interacting with the list.
From the gcode project;
public void onManagedDrawChildren(final Camera pCamera) {
final ArrayList children = this.mChildren;
final int childCount = children.size();
for(int i = 0; i < childCount; i++) {
children.get(i).onDraw(pCamera);
}
}
As this is running in a separate thread, it is likely that you are removing an object from the children ArrayList
while the loop is iterating. To fix this you should call your changes to the children ArrayList
like jmr499485 explains in his answer.
java.lang.IndexOutOfBoundsException: Invalid index 13, size is 13
The only item in your code I can see that would be causing this is the statement questionText.detachSelf();
which you have used in many places. You should instead use;
runOnUpdateThread(new Runnable() {
@Override
public void run() {
questionText.detachSelf();
}
});