Java – Android Eclipse Classpath – want to add classpath container path but eclipse won’t let me

androidclasspatheclipsejava

I'm using Eclipse to learn to develop Android applications in Java. I haven't used Eclipse before.

The project I'm trying to use (supplied by OReilly as part of 'Android Application Development') is MJAndroid. When attempting to run the project, the Run fails, and the Problems tab mentions com.java.Object can't be found, and Eclipse asks me to check the build path. Clicking
Properties -> Java Build Path -> Libraries, the message 'Unable to get system library for the project' is displayed.

On a working project, Properties -> Java Build Path -> Libraries has an entry for Android 1.1, which if I click Edit, has the classpath container path of com.android.ide.eclipse.adt.ANDROID_FRAMEWORK.

It seems a simple matter of adding the correct container path to my non-working project. However Eclipse seems determined to make this as difficult as possible. No matter what I chose to add – jars, externals jars, variables, libraries, class folders, external class folders, nothing seems to take the form of 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK' that the 'Android 1.1' entry on the working app has.

How can I add this namespace to my project so it resembles the working one?

I'm quite sure it's a problem with Eclipse's somewhat odd user interface. Frankly there' nothing I'd prefer more than a file to modify and set such information – my background is in Python, and the whole eclipse environment seems an unnecessary burden.

Best Solution

I had faced the same issue when I imported a sample code downloaded from the internet. I am using android sdk 1.5 with 0.9 ADT plugins. Here is a simpler way to fix the andoid library reference issues

  • Right click on the project which has issues and select properties
  • Select the appropriate Android build (1.1, 1.5 or 1.5 with google api) and say ok
  • Again right click on the project and select "Android Tools > Fix Project Properties"
  • Fix the imports once (if required)
  • Refresh the project and you should be ready to go without any manual editing