When using new functions in Eclipse you will run into this problem before you import the needed class. E.g. “Log cannot be resolved”, “TextView cannot be resolved to a type” or something like This cannot be resolved to a type.
If you hover your mouse over the error line you’ll get the following. In this case it’s because it’s missing the import android.widget.TextView.
You can do three things, either manually add “import android.widget.TextView”. Or select the first option in the dropdown “Import ‘TextView’ (android.widget). Or the most efficient way using “Ctrl + Shift + O”. That’s the letter O and not zero.
You might encounter this window “Organize Imports” when using the shortcut. Here using the Log function in Android it’s the android.util.Log class I need to add to import.
Select the import and press finish. Eclipse will add the missing imports and remove possible duplicate or unnecessary imports.