error (1)

Android ‘R’ Class

Just putting this up here in case anyone else falls into the trap I just did.

If you’re writing an Android application, and add a new Activity, you might want to refer to a generated class (from XML) using the ‘R’ class.

In Eclipse, it automagicly imports “android.R” as soon as you use it to attempt to access R.layout for a setContentView( R.layout.something ) call – this then breaks the class!

This is because the class is included as part of your project, but can be accessed via static calls from the Android API, causing a fun name conflict.

Simple workaround – remove the import line! Then your local copy will be used over the static methods of the class described in the API, fixing the issue.