"Unable to get system library for project" after I upgraded to Android SDK 2.3 and ADT 8.0
Asked Answered
H

26

63

Today I upgraded to Android SDK 2.3 and I also upgraded the Eclipse Plugin Androi Developer Tools 8.0 (from 0.9.9). I also upgraded my Java Development Kit to 1.6_22.

Now in Eclipse I get many errors in all my Android projects.

The error messages are like:

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files.

How can I fix this so I can use my Android projects again?

In the Build Path for these projects, I don't have any references to an android.jar but a message:

Unable to get system library for project

Halfmast answered 7/12, 2010 at 1:21 Comment(0)
D
40

That is rather difficult to answer, given the limited information you have supplied. Here are some suggestions:

  • Make sure that an appropriate android.jar is in your build path, since that is where java.lang.Object would come from.

  • Do a Project > Clean, to make sure you have 1.6 .class files, in case that is part of the problem.

  • Try creating a new project from scratch and see if that works.

Defrayal answered 7/12, 2010 at 1:39 Comment(10)
The android.jar seems to be in my Build path. I have already tried with Clean but it doesn't help. I get the same errors when I create new projects.Halfmast
If I look in the Properties for my project, under "Java Build Path" there is a message: Unable to get system library for project. I think this is the problem, but I don't know how to fix it.Halfmast
@Jonas: Go into Window > Preferences > Android and make sure your SDK is still configured with the appropriate directory.Defrayal
I was wrong, I just get this error on old projects and not on new projects and the old doesn't seem to have an android.jar in the build path, but a message Unable to get system library for project.Halfmast
@Jonas: You might get that if you have your project configured for some target that you no longer have on the system (e.g., you removed it as part of your round of upgrades). In the project properties dialog, go into the Android area and make sure you have a valid target checked.Defrayal
Thanks, that fixed most of the problems. No target were selected. But I use MapView from Google Maps in one project, and I don't have a target with Google Maps API.Halfmast
I had this same problem and I solved it with @Defrayal comment (the 3rd one).Sequent
@CommonsWare's comment resolved it for me as well. Thank you!Baleful
@Defrayal You are a true Android Patriot! Suddenly all my errors disappeared in one fell swoop! Thanks!Mouldy
what information should have been given, so it wouldn't be "limited" any more?Arcturus
A
69

For me, the problem was that in the Project settings - Android tab, I had no Android version selected.

Alimentation answered 31/1, 2011 at 12:46 Comment(4)
For me too, but with the addition that selecting a version in the Androids simply unset itself after reopening the preferences.Nolly
This is held under Project/Properties (not Settings) on my version of Eclipse. The solution (changing Android 4.3 Build Target from unchecked to checked) worked for me, but I don't understand how it became unchecked - the project worked fine earlier and seemed to stop working without any significant change.Ebony
I had a target selected, out of the three I'd installed, but selected a different one anyway, applied, then selected the original one and applied. then build. it fixed for me. just like Iker Martin's answerArcturus
Worked for me too on Android 6.0Eisk
D
40

That is rather difficult to answer, given the limited information you have supplied. Here are some suggestions:

  • Make sure that an appropriate android.jar is in your build path, since that is where java.lang.Object would come from.

  • Do a Project > Clean, to make sure you have 1.6 .class files, in case that is part of the problem.

  • Try creating a new project from scratch and see if that works.

Defrayal answered 7/12, 2010 at 1:39 Comment(10)
The android.jar seems to be in my Build path. I have already tried with Clean but it doesn't help. I get the same errors when I create new projects.Halfmast
If I look in the Properties for my project, under "Java Build Path" there is a message: Unable to get system library for project. I think this is the problem, but I don't know how to fix it.Halfmast
@Jonas: Go into Window > Preferences > Android and make sure your SDK is still configured with the appropriate directory.Defrayal
I was wrong, I just get this error on old projects and not on new projects and the old doesn't seem to have an android.jar in the build path, but a message Unable to get system library for project.Halfmast
@Jonas: You might get that if you have your project configured for some target that you no longer have on the system (e.g., you removed it as part of your round of upgrades). In the project properties dialog, go into the Android area and make sure you have a valid target checked.Defrayal
Thanks, that fixed most of the problems. No target were selected. But I use MapView from Google Maps in one project, and I don't have a target with Google Maps API.Halfmast
I had this same problem and I solved it with @Defrayal comment (the 3rd one).Sequent
@CommonsWare's comment resolved it for me as well. Thank you!Baleful
@Defrayal You are a true Android Patriot! Suddenly all my errors disappeared in one fell swoop! Thanks!Mouldy
what information should have been given, so it wouldn't be "limited" any more?Arcturus
B
27

I had this problem even though I had a valid target selected. I fixed it by changing to a different target, applying changes and then changing back. That seems to have sorted it.

Bobodioulasso answered 4/4, 2011 at 12:48 Comment(1)
Yes, this actually re-created the entry for (in my case) Android 2.2 in my Java Build Path, which had been replaced by "unable to get system library for the project" after I installed a number of items. Now everything works as before.Coimbra
C
21

Project->Properties->Android : Select another Android Target (in my case Android 4.0.3) -> Apply changes. THEN select again your default Android Target, and that is all.

Hope this help.

Ceuta answered 30/5, 2012 at 13:56 Comment(1)
Thanks, it works. Somehow it lost the path to android.jar, just uncheck and check again , it will workHausa
C
3

This problem was caused for my old projects on a new machine that did not have an older Android SDK installed.

To fix, simply go into project.properties and observe your old version number:

# Project target.
target=Google Inc.:Google APIs:3

Simply update the version number, like so:

# Project target.
target=Google Inc.:Google APIs:7

You will find that Eclipse then picks up the right SDK version and starts working.

Cogitation answered 20/2, 2012 at 21:6 Comment(1)
Worked for me. The project was referencing SDK 9 (which wasn't installed). When I edited the android version in the UI, the checkboxes wouldn't stay checked. Editing project.properties fixed things and allowed me to select the correct SDK version.Gidgetgie
G
3

No need to create a new project from scratch. If "Fix Project Properties" or "Add Library > Android Classpath Container" does not work, "project.properties" file might be missing in the root of your project folder. Add that file and set the Android target in the Project properties, re-add the Android Library, Fix Project Properties again, Android System Library should now be included in your project. Rebuilt, and you are good to go!

From my personal experience. For self documenting as well, since this happens quite often on me:

Eclipse Helios SR2
Android SDK R.20
Android NDK R8b
OSX 10.7.4
Gardy answered 22/8, 2012 at 9:24 Comment(0)
B
2

In my case the issue was related with the missing library path from the properties>android>library.

I cleared and re-entered the library paths in project.properties file

Boswell answered 19/11, 2013 at 4:56 Comment(0)
B
2

Had EXACT issue as the original Question! Had not done anything but close my project/Eclipse and was startled by all the errors upon reopening.

In my case I only needed to do was change/switch workspaces. o_O When I reselected my original workspace I then found everything was resolved and working again!

Beckiebeckley answered 15/1, 2014 at 12:56 Comment(1)
I also just closed and then reopened the project then everything worked.Pointsman
W
1

Please see your .classpath file, and see if all reference lib projects or src projects are added with correct path and name.

Whooper answered 10/8, 2011 at 4:42 Comment(0)
R
1

tl;dr: also check for stale SDK paths in the "local.properties" file.

Here's how I fixed it: I went through the answer given by Richard Le Mesurier, and also checked the path to the Android SDK in Window > Preferences > Android as mentioned by CommonsWare (since I did indeed change the SDK directory a while ago), however it still couldn't find it.

Then I noticed that I had a file called "local.properties" which referenced the old location for "sdk.dir". I changed that to the new location to match what was in Window > Preferences > Android. Then deselected the build target in Project > Properties > Android, hit Apply, re-selected it, and hit OK and cleaned the project. That worked! Thanks all!

Rhapsodize answered 27/11, 2011 at 1:43 Comment(1)
ticking in one of the boxes in <project> -> Properties -> Android -> Project Build Target did it. There was none selected. Strange. I've also copied android-support-v4.jar to a freshly-created <project's root>/libs folder - don't know if it has to do with anything because in itself it didn't help, but then the tick did.Arcturus
T
1

i have also encoutered this and solve it by changing the android choice in project properties. My error is because the project can't find proper lib from the android SDK. Then fix the project using android fix tool in right click of project, clean it and then correct.

Treasurehouse answered 18/1, 2012 at 15:25 Comment(0)
P
1

I had this problem come out of nowhere.

What worked for me was to right-click the project, select Android Tools, Add support Library..

It is the android.jar that is missing, and this restores it.

Perspicuous answered 14/5, 2012 at 6:24 Comment(0)
O
1

Another possible explanation is that Eclipse has forgotten its Android plugin. This can happen if you switch workspaces, as happened in my case. I tried to re-import an existing Android project, and it couldn't find the basic java system libraries, since it was pointing to the standard android jars. Reinstalling the android plugin (Help->Eclipse Marketplace, then search for "Android" and pick "Android Development Tools for Eclipse") fixes it.

Outtalk answered 15/8, 2012 at 0:36 Comment(0)
C
1

I right clicked project and Closed it. Then reopened it. That fixed the problem.

Clifford answered 27/3, 2013 at 16:17 Comment(0)
E
1

In my case, ADT needed update (in Eclipse menu Help/Check for Updates, or Help/Install New Software). Check your ADT!

Enlistee answered 27/5, 2013 at 12:46 Comment(0)
N
1

I tried several options mentioned here, but nothing worked. Then I rebooted my Ubuntu machine and started Eclipse again. Then everything was solved. Just reboot.

Newmint answered 14/8, 2013 at 15:56 Comment(0)
A
1

java.lang.Object cannot be resolved in Eclipse

This problems started to appear recently for me after I upgraded ADT. As suggested above, when I uncheck+Apply/check+Apply project build target it would help , but the problem would come back eventually. So instead I just added android.jar explicitly to the build. This is the entry in the .classpath file

    <classpathentry kind="lib" path="/Applications/adt-bundle-mac-x86_64/sdk/platforms/android-19/android.jar"/>

This is more of a workaround as I would have to change it every time I change the SDK version, but at least no need to play with properties to get it to build when I restart Eclipse.

Assent answered 14/7, 2014 at 19:24 Comment(0)
G
0

Try cleaning your project, that might help.

On eclipse, click on the menu item above called "Project", then click on "Clean Build". On that screen, check the checkbox that says "Clean projects selected below", select the project(s) that's giving you problems, and click Ok.

It will rebuild your project and that usually helps with strange eclipse errors like this.

Gausman answered 7/12, 2010 at 2:2 Comment(2)
Update your ADT on eclipse, they just pushed a new version to deal with some bugs: twitter.com/#!/romainguy/status/12222143299330050Gausman
I actually fixed this problem as CommonsWare described. And now I upgraded to ADT 8.0.1 and got the same problems again, but his fix solved it again.Halfmast
M
0

Try to create new project like this then try it

Screenshot of 'New Android Project' window

Moony answered 28/11, 2011 at 13:9 Comment(1)
after that clean the project and then try to run itMoony
S
0

In my case, my project.properties had android-8 listed as the target, which I didn't have installed.

Stylus answered 3/1, 2012 at 18:3 Comment(0)
A
0

my case was not created the right AVD

after AVD created, go to project Property and find Android, select the right SDK version and then go to JAVA Build Path, delete the library (Unable to get system library for project) and add android library.

Alanaalanah answered 13/2, 2012 at 6:59 Comment(0)
A
0

The best way here as I tried before, is to create a new project and choose :

create a project from an existing source and choose the location of the android project that you want to import, then next, you will see the build target of android like : 2.3.3 or 2.1 ..

Just choose one of them then finish!

You are done! ..

Amritsar answered 28/4, 2012 at 20:31 Comment(0)
F
0

Remove the folder libs in your project

Ferrate answered 14/6, 2013 at 19:33 Comment(0)
S
0

Had the same issue (red erros all over my java source files) Solution was simple:

  • step 1. In the manifest file raise the version to android:minSdkVersion="8" (I created a new empty project and looked in it's manifest file) (it was originally android:minSdkVersion="4" because i want to support older android versions.)
  • step 2. right click the project and select Build
  • step 3. just to be safe: On the menu: Project Clean and check my project
  • step 4: finally I changed back In the manifest file to android:minSdkVersion="4" and it had no errors.

Hope it works for you.

Sylvan answered 21/3, 2014 at 10:36 Comment(0)
M
0

In my case, The JRE went missing (disapear from Eclipse option).

All I did to fix this is re-add the JRE under Windows -> Preferences -> Java -> Installed JREs.

mine was located at /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Manny answered 22/8, 2014 at 9:57 Comment(0)
P
0

The way that helped me.

  1. Take the following file from the working project: workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/Working-project-name/.indexes

  2. Replace the broken project file: workspace/.metadata/.plugins/org.eclipse.core.resources/.projects/Broken-project-name/.indexes

Pontormo answered 18/11, 2014 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.