174 CHAPTER 6: Android Screen Design: Writing to the Display Using Activity and View
You can see an error in the Eclipse programming code, in Figure 6-3, in fact. Notice that the
Galaxy.java tab is clearly showing several errors in the code contained in it, but the Eclipse code
is not putting the red error X next to the Galaxy.java class in the Package Explorer pane, which it
should be, to show that this class has errors in it! This is an Eclipse bug!
As you can see under the Problems tab, these errors are stemming from Eclipse ADT’s inability to
reference, or “resolve,” the path to the java.lang.Object master class, which is part of the Java
SDK, also known as the JDK.
Let’s utilize this Eclipse error in referencing the JDK to reinforce what we learned in Chapter 5, just to
turn this negative experience into a positive one! As you can see in the editing pane in Figure 6-3,
the String and Galaxy objects that are subclassed from the Java Object are the ones that contain
the red underline, indicating an error. Since the galaxyName variable is a String object, it is also
marked as an error. Thus these are not our own Java coding errors, but errors that are being
generated by Eclipse’s inability to “see,” resolve, or reference, the Java Development Kit (JDK) and
its Object superclass.
The easiest way to fix this is to simply click the red X exit icon at the top-right corner of the
Eclipse IDE, or use a File ➤ Exit menu sequence, to exit Eclipse. Then restart Eclipse, accept the
workspace, and wait for the IDE to load and reference the Java software development kit (SDK,
also known as JDK), and after a while, the red error highlighting will vanish. I have seen online that
developers have said that they had to exit and restart Eclipse several times before Eclipse saw the
JDK again.
If this does not restore the link between Eclipse ADT and the JDK, you might need to “rebuild” your
project. Use the Project ➤ Clean menu sequence, which is shown in Figure 6-4, along with the
Clean dialog this menu sequence brings up, shown in the lower-right corner of the screenshot.
Figure 6-4. Using the Project ➤ Clean menu sequence with the Build Automatically option checked (underneath)