I need help finding the reason why a bug happens only in android...

Hi, I would like to ask a favor finding a bug in my code, there seems to be a bug that only happens in android in this code

on the simulator the game ends then life is less then 11.
n line 1929 and 1929, in the simulator when I comment out either line, the game just goes into a blank screen instead of going to the menu… but with both lines it goes in properly…
even-tho it is working in the simulator, only in Android, when the mouse and the person collide, one or both of them get stuck… but this does not happen in the simulator.

here is the HTML5 version, which does not suffer form the bug. Tom Burger 3 HTML5 English version

and here is the APK https://amjp.psy-k.org/tom-burger/TomBurger3.apk

this is the github where all the code is at: GitHub - amigojapan/TomBurger3Solar2d: Hamburger Simulation game

all help greatly appreciated!
amigojapan

No idea why the problem would be strictly on Android, but here are a few tips:

  1. In your collision detection code, make sure both objects still exist before checking for collision.

  2. You should only check for collision for rat and tom once per frame, so line 1930 is redundant and could introduce issues.

  3. You can troubleshoot in an Android device via ADB; assuming you’re using Windows as your dev machine, just enable USB debug in your device, download the platform tools from the link found here: Solar2D Documentation — Developer Guides | Basics, and on a terminal window run the adb tool like so: adb logcat Corona:v *:s

EDIT:
I would also highly recommend doing an Android Live Build so you have real time code updates on your app. Solar2D Documentation — Developer Guides | Building/Distribution

1 Like

Thanks a lot again Siu,
I will try putting your advice into effect…
I am using Linux out of preference, but i can set up a windows environment if really needed. I think adb should also work on Linux, dunno.

Thanks for looking thru my messy code!

Thanks a lot! you pointed me in the right direction!

after isolating the collision check in each frame, it no longer got stuck with only one function call, and after that I noticed it was freezing only in the game over screen (when the scores were about to be saved) it turns out that I needed to get the proper path to write to in android using path = system.pathForFile( “file.txt”, system.DocumentsDirectory)

it seems I was trying to write somewhere I had no permission, I hope this can help other people too that run into this problem…

1 Like