Wednesday, December 28, 2011

Error handling and typical problems at Android

5. Error handling and typical problems

Things are not always working as they should. This section gives an overview over typical problems and how to solve them.

5.1. Clean Project

Several users report that get the following errors:

  1. Project ... is missing required source folder: 'gen'

  2. The project could not be built until build path errors are resolved.

  3. Unable to open class file R.java.

To solve any of these errors, go to the project menu and select Project -> Clean.

5.2. Problems with Android Debug Bridge (adb)

The communication with the emulator or your Android device might have problems. This communication is handle by the Android Debug Bridge (adb).

Eclipse allows to reset the adb in case this causes problems. Select therefore the DDMS perspective via WindowOpen PerspectiveOtherDDMS

To restart the adb, select the "Reset adb" in the Device View.

5.3. LogCat

The LogCat view shows you the log message of your Android device and help you analyzing problems. For example Java exceptions in your program would be shown here. To open this view, select "Window -> Show View -> Other -> Android -> LogCat" from the menu.

5.4. Emulator does not start

If your emulator does not start, make sure that the androd-sdk version is in a path without any spaces in the path name.

5.5. Error message for @override

The @override annotation was introduced in Java 1.6. If you receive an error message for @override change the Java compiler level to Java 1.6 via right-mouse click on the project -> Properties -> Java Compiler -> Compiler compliance level and set it to "1.6".

5.6. Missing Imports

Java requires that the classes which are not part of the standard Java Language are either fully qualified or declared via imports. In your editor use the click mouse click, select "Source-> Organize Imports" if you see error message with "XX cannot be resolved to a variable".

5.7. Eclipse Tips

To work more efficient with Eclipse, select Window -> Preferences -> Java -> Editor -> Save Actions and select that the source code should be formated and that the imports should be organized at every save

No comments:

Post a Comment

My Headlines

RF Optimization 2G,3G,4G and Wimax

Subscribe Now: google

Add to Google Reader or Homepage