Some times App Inventor 2 apps stop working (well mine sometimes do this, may be your’s don’t!)
Besides looking carefully at your blocks code, there are some additional steps that may be helpful in identifying the cause of the problem.
1. Check your blocks code very carefully to see if you can spot an error in your program.
2. Add a status message area in the user interface (using the Designer) and then in your blocks code, add blocks to assign status texts to this message area. Your status message could include a message indicating what section of your code is running, or to display the values of variables in your program.
3. Add a special “Error handler” to catch and display information when the program encounters a serious problem. The following section is adapted from my tutorial on basic Bluetooth communications.
For most of our App Inventor apps, we ignore potential errors – if errors occur, the app stops running and Android displays error messages.
Our app can intercept the error condition by adding an error event handler to the main screen, Screen1. In the Blocks editor, select the Screen1 component and then select the When Screen1.ErrorOccurred event. Drag this to the Blocks editor and then add the following code.
The ErrorOccurred event has four parameter values (local variables) that contain information about the error. This error handler displays the error values on your device screen, rather than immediately shutting down the app.
To use this code, add a text label to your user interface – in the example above, the label has been renamed to lblStatus.
There is no guarantee that these error values will identify the specific problem but they may give an indication as to where the problem is occurring in your program!