Errors, warnings, and bugs
The most common getting started errors are the syntax errors. They most frequently occur when we mistype a Java keyword or forget to leave a space after a keyword.
The error below occurs if you forget to leave a semicolon at the end of a line of code.
Note
There are occasions when we don't need semicolons. We will see these as we proceed.
Look at this image that shows the error when we type a word the compiler doesn't recognize.
Also, notice that Android Studio is giving us a warning that we have some unused variables. Warnings for example like Field 'horizontalTouched' is never used. You can see these warnings if you hover the mouse pointer over the little yellow lines on the right of the editor window just as we did when looking at the unused import
statements. There are other warnings like this one that indicates that method boom is never called.
Warnings do not have to be fixed for the code to execute but are worth keeping an eye on as they often prompt us to avoid making a mistake. These warnings will be fixed over the coming few chapters.
Most of the time the problem is likely to be a bug. We will now output all our variable values using the printDebuggingText
method.
I will point out lots more common errors as we proceed through the book.