Game opesn to a black screen and then closes

I have a game that runs fine on the simulator but on the device it starts to a black screen and 8 seconds later it closes itself. Logcat shows no errors and there is really no way to debug it. Does anyone know off the top of their head what could be causing this?

Use bunch of prints and see what parts are executed and which one not

Yeah I was afraid it would come down to that lol.

For some reason this was causing it

physics.setGravity(0, 8)

Nothing seems wrong with that line.

how do you know that this line was causing the crash? Did you just comment it out?

If yes then there is more likely something else related to your physics bodies that is causing this.

Yep I put a whole bunch of print statements and narrowed it down to that line. Commented out that line and everything works well now. I only have a few physics bodies and I’m adding them the same way I always have. Not really sure how to debug this one.

So you open your game, do nothing and then it crashes after 8 seconds?

How do you move your physics bodies or what happens with them? Is there any function that may cause a memory leak related to physics? 

Correct open it and it closes after 8 seconds. I have a class I wrote that displays the memory on the screen for debugging and I’ve never seen a memory leak. Actually until you actually start playing the game there are no physics bodies. Those get added later on.

This is really weird, when did you encounter this error first? Which build are you using?

I just noticed it last night it was the first time I built for the device. I’m using 2013.1203

I’m guessing it’s something wrong with my app because I have other apps that use the set gravity and work just fine. I will try to pinpoint why this is happening though.

What device are you using by the way? ;) 

Tried it on a sony xperia play, samsung galaxy note 2 and galaxy s3

Okay then I do not see any other way - check your physics environment (since it seems to be related to gravity/physics) and try to hunt it down :wink:

Good luck!

Use bunch of prints and see what parts are executed and which one not

Yeah I was afraid it would come down to that lol.

For some reason this was causing it

physics.setGravity(0, 8)

Nothing seems wrong with that line.

how do you know that this line was causing the crash? Did you just comment it out?

If yes then there is more likely something else related to your physics bodies that is causing this.

Yep I put a whole bunch of print statements and narrowed it down to that line. Commented out that line and everything works well now. I only have a few physics bodies and I’m adding them the same way I always have. Not really sure how to debug this one.

So you open your game, do nothing and then it crashes after 8 seconds?

How do you move your physics bodies or what happens with them? Is there any function that may cause a memory leak related to physics? 

Correct open it and it closes after 8 seconds. I have a class I wrote that displays the memory on the screen for debugging and I’ve never seen a memory leak. Actually until you actually start playing the game there are no physics bodies. Those get added later on.