user3305142
user3305142

Reputation: 227

app works on simulator but not on android

I tested my app on android phone and it stopped in the middle of playing, it stops when it is about to change scene.(It works on the simulator.) I debugged it using the instructions by: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

This is what it gave me in the cmd.

beginning of /dev/log/main
.....
I/Corona <24200>:cannonCharge   
I/Corona <24200>:shot
I/Corona <24200>:event listener   
I/Corona <24200>:Ball is colliding   
I/Corona <24200>:Before changing scene

Then it just stops here and then a popout on my phone screen says balloon game has stopped. This part of the code i think went wrong.

   if (event.other == balloons[1])  then
     scene.updateScore()
     print('Ball is colliding')
     balloon1:removeSelf()
     balloon1 = nil
     balloonText1:removeSelf() 
     balloonText1 = nil
     audio.play(pop)
     print('Before changing scene')
     storyboard.gotoScene("correct1", "fade", 1000)
   end
   ...

I thought maybe its the file name because I know android is case sensitive so i changed all the file names to lower case. The images showed so I don't think theres any problem with them but also checked just in case. Up to now I don't know what else I could try, any suggestions? And I tried removing some codes and found out everything works up until storyboard.gotoScene("correct1", "fade", 1000). I can't see any problems with it and even tried to link it to a different scene "results" which is also the same result.

Upvotes: 1

Views: 431

Answers (2)

Kumar KS
Kumar KS

Reputation: 521

The code above is fine and i cant find any mistake, so upload the other part of the code so that i can check it. General advice is make sure that your are using the correct file names and the scene names .

Upvotes: 0

Oliver
Oliver

Reputation: 29483

When faced with such situation, one technique that works well is to add many print statements in the code so that you can find the last line that gets executed. Here you have a print statement before the scene goto but unless you have one after, there is no way of knowing if that is where it hangs.

Once you have done that, you start removing code (comment out) until the problem disappears. The problem is not necessarily the line that hangs; it could easily be in the lines prior, even something done at initialization. So you comment out big blocks of code but leave the structure (like all the scene gotos), just comment out things like audio, buttons (except the one required to trigger the goto), etc. When a code removal makes problem disappear, you at least have something to look at (wrong config values, etc).

Upvotes: 1

Related Questions