Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Eclipse Classpath - want to add classpath container path but eclipse won't let me

Tags:

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.

like image 741
mikemaccana Avatar asked Jul 07 '09 23:07

mikemaccana


People also ask

How do I enable configure build path in eclipse?

Procedure. In Eclipse select the web project and right-click Build Path > Configure Build Path. This will display the Java Build Path window. Add the CICS and Liberty libraries, click Add Library > CICS Liberty libraries > Next > Finish.

How do I find the classpath in eclipse?

In the Properties page, select the Java Build Path page. On the Libraries tab, click Add Variable for adding a variable that refers to a JAR file. The New Variable Classpath Entry dialog appears which shows all available classpath variables.


2 Answers

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
like image 160
Shreedhar Kotekar Avatar answered Oct 05 '22 22:10

Shreedhar Kotekar


I faced this same problem after importing a project through GIT. The problem was that I didn't have the same target android platform installed, and the build path somehow got corrupted.

The first obvious thing i did was changing the target sdk in the project.properties, but even after cleaning up the project and Android Tools > Fix Project Properties, it didn't help and I was still getting the build error.

My solution after wasting close to 1 hour trying to figure this out?

RESTART ECLIPSE 

Everything worked fine after that. Eclipse is pretty fickle. Only through years of experience you'll then understand her well. :)

like image 22
Stark Avatar answered Oct 06 '22 00:10

Stark