by Jon (Updated on 2015-10-12)
Call for Help: This article is incomplete. Want to help us improve it? Propose edits to this article.
It's rare for a game to run perfectly the first time you make it. Bugs and crashes are an inevitable part of the game development lifecycle. This guide exposes you to the various tools avilable for debugging your games.
Your game's logs record much of what goes on while your game is running as well as any additional information you decide to add in.
Turn on the Log Viewer by selecting View > Log Viewer from the main menu.
To add information to the logs, use the print block, located under Flow > Debug in the palette.
This can be particularly useful when something goes wrong and you want to know the value of an attribute, for example.
Before your game runs, it has to compile. Compiling means translating all the blocks and code for your game into a form that the computer or device understands.
Errors in your behaviors are generally caught by Stencyl, with the offending behaviors automatically opened up. Most of the time, you're able to figure out what's wrong. That's not what we're focusing on here.
What we're focusing on are the cases where your game gets stuck in the "Compiling..." state seemingly forever. The first thing to realize is that your game isn't stuck. It hit an error that we couldn't detect for reasons like these.
Although we try to scan and identify common errors, some inevitably slip through the cracks. Here's what you can do to stay informed during the process, so you aren't left waiting forever.
Turn on the Log Viewer before you run a game. (View > Log Viewer)
Run your game.
The Log Viewer should continually spew out new lines. It may slow down at times, but progress should be steady.
If it stops, scan the last page or so worth of lines for errors.
If you locate an error, try to understand what it means and search on Google. This is most useful for certificate errors where the solutions to such issues are well documented on Q&A sites such as StackOverflow.
Crashes are errors in your game’s logic or the Stencyl engine that cause the game to suddenly quit. Many types of errors can cause crashes. The most common ones include the following:
The Android Device Monitor gives you visibility into the raw Android system logs. They can be daunting for an average user to go through, which is why they're filtered out by default. However, when your game crashes, they can be your main source of information.
Note: This section tells you how to use the Android Device Monitor. The Debugging Tips section helps you reach the root cause of the crash.
Select Debug > Android > Launch Device Monitor from the main menu.
The Android Device Monitor consists of 3 sections. The left section lets you pick what device to inspect. The center section provide advanced information geared towards programmers. The bottom section provides the raw logs. We'll mostly focus on the bottom section.
Android logs can appear complex and overwhelming at first. Here are a couple things to look out for.
Putting the elements discussed previously together, here's what you can do debug your game when it crashes.
This will cue you in on what actually caused the problem.
See if you can recognize your behavior names, which can sometimes be printed out in a stack trace (a "blame" list that traces all the steps leading to an error. Is it something you can trace back to your game and fix?
If you can’t recognize the faulty behavior, disable suspicious behaviors, based on what you know causes the crash, until the game no longer crashes.
Once you’ve figure out the offending behavior(s), try to narrow it down to particular blocks, if possible. If you are unable to fix the issue, or if you think it’s a problem on our end, report it on the forums and include the following info.