0

I'll preface this by saying that I made an error by walking away from my code after a long session of coding. To my dismay I'm now receiving an IndexOutOfBoundsException when I do a certain function in the game I'm developing. I'd love to post the code to help locate the problem. The thing is I'm having trouble finding where in my 3,500 + lines of code the problem really lies. I've tried removing a few different methods in hopes that it would reveal the culprit but this was to no avail. Here is what I do know for sure.

I set a break point at a place in the code slightly before where The error occurs. The method I placed it before runs and finishes with no problem according to log entries I set in the logcat.

in debug mode it seems that the engine is catching an exception. Here is the logcat message:

12-15 00:41:46.866: E/AndroidRuntime(3395): FATAL EXCEPTION: UpdateThread 12-15 00:41:46.866: E/AndroidRuntime(3395): java.lang.IndexOutOfBoundsException: Invalid index 6, size is 6 12-15 00:41:46.866: E/AndroidRuntime(3395): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 12-15 00:41:46.866: E/AndroidRuntime(3395): at java.util.ArrayList.get(ArrayList.java:304) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.engine.handler.UpdateHandlerList.onUpdate(UpdateHandlerList.java:47) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.entity.Entity.onManagedUpdate(Entity.java:1395) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.entity.scene.Scene.onManagedUpdate(Scene.java:284) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.entity.Entity.onUpdate(Entity.java:1167) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.engine.Engine.onUpdateScene(Engine.java:591) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.engine.Engine.onUpdate(Engine.java:586) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.engine.FixedStepEngine.onUpdate(FixedStepEngine.java:52) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.engine.Engine.onTickUpdate(Engine.java:548) 12-15 00:41:46.866: E/AndroidRuntime(3395): at org.andengine.engine.Engine$UpdateThread.run(Engine.java:820)

Is anyone familiar with a problem similiar to this? I've read a few posts about similar problems where there was an object being disposed causing the error. I'd love it if that were the case, I just cant find anything that would be getting disposed and causing this problem.

Nibb
  • 1,801
  • 1
  • 13
  • 19
  • I haven't touched AndEngine in over two years but seems like the game tick calls a Scene to update() and the scene contains a list of Handlers which are no longer there. You will have to debug AndEngine code I guess and/or remove code from your game until you can figure out some more info. – Martin Marconcini Dec 15 '13 at 07:00
  • By Any chance have you mixed touch listeners or updatehandler with a "remove method" such as removemodifier, detachentity, removetouchlistener? I haven't touch any andendgine project in a while, but in GLES 2 there was a problem with synchronization between threads when you remove any entity from the engine while other was or was going to use it in the same cycle/tick. Or when you remove a touch listener inside the on touch method. – gian1200 Dec 15 '13 at 07:16
  • these kind of errors are almost always the result of deleting an entity outside of the update thread. Check your code where you may be removing sprites, etc and be sure that those calls are done on the AndEngine updateThread - you can use runOnUpdateThread. Search SO for lots of answers related to this - like http://stackoverflow.com/questions/11077560/why-am-i-getting-an-update-thread-null-pointer-exception-android-andengine – jmroyalty Dec 15 '13 at 14:23

1 Answers1

0

It seems related to answer provided for question BaseGameActivity.runOnUpdateThread() vs. Entity.registerUpdateHandler()

The answer contains tips on where to start looking. Hope it helps.

Community
  • 1
  • 1
Daniel Backman
  • 5,121
  • 1
  • 32
  • 37