App works on simulator but not on device

Hi,

    I’m currently trying to make a trampoline class in a separate module for use in a game.  I have made the center of the trampoline (the actual part that is used for jumping) into an animation that plays whenever my character falls on the trampoline.  The problem I’m having is that when I place the animation in my code it works fine in the simulator but it doesn’t work on my device.  The animation is off of a sprite sheet.

    What’s weird is that I made a plunger class which adds an animation the same way and it works fine.  I was wondering if it could be a path error or if somehow a consistent error in the build could be affecting it.  I’m pretty new at Corona so I don’t have a great idea as to what could be the issue.

     Another interesting effect of this is that if I add the animation it will completely disable any touch response from the screen and also disable other animations on screen.  Again, this is only on the device.  Everything works in the simulator.

Here is the code that I add.

    local sheet = graphics.newImageSheet( “images/general/LevelAssets/trampoline/centerSheet.png”, { width=973, height= 95, numFrames=75 } )

    local trampoline = display.newSprite( sheet, {name = “centerBounce”, start = 1, count = 25, time = 200, loopCount = 1})

    trampoline.x = 150

    trampoline.y = h/2 - 100

    trampoline.xScale = 1/6

    trampoline.yScale = 1/6

What is more interesting is if I change the sprite sheet to another sprite sheet that I use for this project everything works on the device.  I have deleted and re-made the sprite sheet twice to no avail.

If anyone could help on this I would be extremely grateful.

Rob

Hi Rob.  Usually when we see “It runs in the simulator but not on the device” its because there is an error occurring on the device.   Frequently its due to a file name problem since devices are case sensitive and the simulator is not.  But the only way to know for sure is to look at your device’s console log and find the error.  We have a blog post that covers how to do that here:
 

http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Please read that and if the error isn’t obvious to you, you can post the error back here and we can try and help you.  I’m going to guess it has something to do with a case sensitivity problem in that filename. But learning to use your debugging tools is important, so lets start there.

Rob

Hi Rob.  Usually when we see “It runs in the simulator but not on the device” its because there is an error occurring on the device.   Frequently its due to a file name problem since devices are case sensitive and the simulator is not.  But the only way to know for sure is to look at your device’s console log and find the error.  We have a blog post that covers how to do that here:
 

http://www.coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

Please read that and if the error isn’t obvious to you, you can post the error back here and we can try and help you.  I’m going to guess it has something to do with a case sensitivity problem in that filename. But learning to use your debugging tools is important, so lets start there.

Rob

Rob, 
 
I know this is a very old thread, and I considered creating a new one. However, I am having the same issues. I have an app that I have been working on, and it works fine on the Corona Simulator (as far as I know and can see). I have made several different builds, and sometimes upon APK install the app runs fine. Then if I exit the app and go back in, it takes me to the main menu I have set up, but as soon as I hit “Play” it crashes. I have two different logs, one of it working and the other of it crashing which I got from ADB. I don’t really understand why my code isn’t working well.

Any advice on figuring out why my app crashes while “composer” is changing the scene, but only on the second time loading the app?

One thing I have thought and tried to implement is the home/back/menu buttons (I’m using gs3 as my test device). Could this be caused from not properly removing my event listeners upon pushing back or home?

Brian H.

Hi Brian,

I think you just answered your own question with that. When there are inconsistencies with navigation or when you load something up the second time, the first thing that you should look for are places where you forgot to remove any listeners. From what I’ve seen working with Corona, any kind of wild/unexpected performance usually comes from a stray listener not being properly managed.

As for my problem on this thread, the reason everything was going haywire was due to the image sizes that I was using. I’ve noticed that even though some phones/systems can use a 2048px x 2048px size image that it can have some very crazy effects. The system in this case couldn’t handle size and that caused the non-response of the phone. In short I’d say a best practice would be to keep all your images under 1024x1024 resolution.

Rob

Thank you Rob,

I will try and find my listeners and make sure I am cleaning them up properly.

Brian H.

One other thing to ask here is this:  are you exiting the app or suspending the app and when you restart it, are you restarting from cold or resuming from having been suspended?  It kinda changes the things to look for.

Rob

I have tried both. 

regardless of how recent I have used/installed it, I always get to the main menu. When I click play the first time right after install, 2/5 times it works, and the other 3 it crashes. If it crashes, no matter what I do it always crashed until I uninstall/reinstall. If it works and I use the back button to exit my app, it continues to work via suspension and also from cold restart. If I exit using the home button and try to get in cold or through the suspension, it crashes. 

It is strange. I have looked through my code and I thought I handled all my listeners, but it doesn’t seem to help at all.(maybe this is what I get for trying something I have no idea about :wink:

Thanks for you help/insight

Brian H.

I you are saving data, perhaps your save file is getting corrupted some how.  Try installing after removing to make sure you come in with a clean start.

Rob

I thought about that at first as well, but as far as I know of I am not saving anything at all. Right now it is just pre-loading a level, with preset functions/variables. Once you complete the level it restarts, back with the same presets and everything. I did go through my code and make sure all my event listeners are being handled and removed, but I am still having it crash, but only after calling the composer scene change.

Any other advice? You have already been a great help thank you

Brian H.

What’s going on in your console log?

Rob, 
 
I know this is a very old thread, and I considered creating a new one. However, I am having the same issues. I have an app that I have been working on, and it works fine on the Corona Simulator (as far as I know and can see). I have made several different builds, and sometimes upon APK install the app runs fine. Then if I exit the app and go back in, it takes me to the main menu I have set up, but as soon as I hit “Play” it crashes. I have two different logs, one of it working and the other of it crashing which I got from ADB. I don’t really understand why my code isn’t working well.

Any advice on figuring out why my app crashes while “composer” is changing the scene, but only on the second time loading the app?

One thing I have thought and tried to implement is the home/back/menu buttons (I’m using gs3 as my test device). Could this be caused from not properly removing my event listeners upon pushing back or home?

Brian H.

Hi Brian,

I think you just answered your own question with that. When there are inconsistencies with navigation or when you load something up the second time, the first thing that you should look for are places where you forgot to remove any listeners. From what I’ve seen working with Corona, any kind of wild/unexpected performance usually comes from a stray listener not being properly managed.

As for my problem on this thread, the reason everything was going haywire was due to the image sizes that I was using. I’ve noticed that even though some phones/systems can use a 2048px x 2048px size image that it can have some very crazy effects. The system in this case couldn’t handle size and that caused the non-response of the phone. In short I’d say a best practice would be to keep all your images under 1024x1024 resolution.

Rob

Thank you Rob,

I will try and find my listeners and make sure I am cleaning them up properly.

Brian H.

One other thing to ask here is this:  are you exiting the app or suspending the app and when you restart it, are you restarting from cold or resuming from having been suspended?  It kinda changes the things to look for.

Rob

I have tried both. 

regardless of how recent I have used/installed it, I always get to the main menu. When I click play the first time right after install, 2/5 times it works, and the other 3 it crashes. If it crashes, no matter what I do it always crashed until I uninstall/reinstall. If it works and I use the back button to exit my app, it continues to work via suspension and also from cold restart. If I exit using the home button and try to get in cold or through the suspension, it crashes. 

It is strange. I have looked through my code and I thought I handled all my listeners, but it doesn’t seem to help at all.(maybe this is what I get for trying something I have no idea about :wink:

Thanks for you help/insight

Brian H.

I you are saving data, perhaps your save file is getting corrupted some how.  Try installing after removing to make sure you come in with a clean start.

Rob

I thought about that at first as well, but as far as I know of I am not saving anything at all. Right now it is just pre-loading a level, with preset functions/variables. Once you complete the level it restarts, back with the same presets and everything. I did go through my code and make sure all my event listeners are being handled and removed, but I am still having it crash, but only after calling the composer scene change.

Any other advice? You have already been a great help thank you

Brian H.

What’s going on in your console log?