Handling Errors in Eclipse

As you are programming your application, you will notice the red lines that come up. There will also be red squares to their left, and red marks on the folders in Package Explorer, as in Figure 12-12. These appear because of errors in your code.

images

Figure 12-12. What happens when you get an error on Eclipse

The Eclipse IDE makes it painfully obvious when your program has errors because your program will not run with them. Your only course of action is to correct them.

Notice that my error in Figure 12-12 is simple spelling. If only all errors were this simple to fix! If you hover your cursor over these errors in the code, Eclipse will tell you what it believes the problem is. It will even tell you how it believes that you can solve the problem. Oftentimes, the error occurs because an import statement is needed, and that is easy to detect when you click the error. Eclipse’s suggestions are often quite helpful.

Errors that occur when your program calls upon something that isn’t there, however, don’t correct themselves automatically. For example, if you set a background, but forget to upload your background to the drawable file, there will be an error. You might find that when you upload the file, you still have the error. You should probably click Refresh or Save All in cases like this. You’ll find that the red Xs should be gone if you have done it right.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.98.18