5

I've had a project built by eclipse saved, then my computer sort of died. When I fixed it and reformatted I redownloaded eclipse and such. Actually, when I press on "eclipse.exe" it shows me the eclipse juno icon but the window's name is Java- ADT and and it looks kind of differently. I've installed the ADT Plugin and all the Android APIs but when I import my project, when it opens the classes lets say, it doesn't recognize anything. I mean, Strings, classes, imports, android, nothing.

It says: The import android cannot be resolved. Or: String cannot be resolved as a type.

Does anyone have an idea?

BTW: XML works fine.

McShpoochen
  • 71
  • 1
  • 1
  • 4

2 Answers2

7

Go to Menu(Windows) ->Preferences -> Java -> Installed JREs and make sure your JREs are available and appropriate one is selected. If not (I hope, that's the case), add the libraries by using Add button in the right side and browsing the JRE installed location.

In addition to above step, go to Right Click(project) -> properties -> Java Build Path -> libraries. Again make sure, right libraries and Jars are selected there and valid. If not, add/correct them.

Yogendra Singh
  • 33,927
  • 6
  • 63
  • 73
  • Thanks Yogendra, but I'm new at this so I'm not really sure what JREs I need and the same, for libraries. I have JRE 7 checked when I enterred Installed JREs. Is that ok? – McShpoochen Nov 16 '12 at 19:09
  • @McShpoochen: JRE --> Java Runtime Environment. Looks OK(plase validate the location mentioned is valid folder in your system and has libraries inside). Did you validate the second step as well i.e. your project level configuration? – Yogendra Singh Nov 16 '12 at 19:11
  • No sorry, I don't really know what libraries and jars I need. :\ – McShpoochen Nov 16 '12 at 19:31
  • @McShpoochen: At least validate the location showing in step-1 is available in your file system. Would you mind sharing that location with me? Also check the entries in step2, and share me what all you see there. – Yogendra Singh Nov 16 '12 at 19:33
  • 1) jre7 - installed at C:\Program Files\Java\jre7 2) JARs and class folder on the build path: com.android.ide.eclipse.adt.LIBRARIES - Access rules: No rules defined - Native library location: (None) Unable to get system library for the project - Access rules: No rules defined - Native library location: (None) – McShpoochen Nov 16 '12 at 19:51
  • @McShpoochen:I think, step2 is showing the problem -`Unable to get system library for the project`. Select and delete that entry. Then click on `Add Library` and then select `Android` related entry you see in the next popup. – Yogendra Singh Nov 16 '12 at 19:58
  • When I do that, the newly added library is still "named" Unable to get system library for the project. Any chance to bypass it? – McShpoochen Nov 16 '12 at 20:02
  • Pretty much anything I thought is related to Android devloping in Help -> Install new software -> And then most of the stuff there. Also, in SDK Manager, all Android development tools and APIs. – McShpoochen Nov 16 '12 at 20:07
  • Also, I'll add - when trying to File -> New -> Android Application Project, it enables me to configure and create another project, of which everything is recognizable. Would you suggest opening a new project and simply copying the code and create the same classes as the old project? Or is it a deeper problem I have to fix in order to work correctly. – McShpoochen Nov 16 '12 at 20:09
  • @McShpoochen You can do that, but before that try one thing. Open the navigator view for your project (window ->show view -> navigator), your should see `.classpath` and `.project` files in root folder of the project. Compare the entries here from these files with same files of the new project where its working. If some differences, simply copy them from working project files to current ones. Save the files, refresh the project. It should be fine. – Yogendra Singh Nov 16 '12 at 20:57
  • There are no differences, it's simply identical. Then a new project with a copy of all code? – McShpoochen Nov 17 '12 at 01:46
  • @McShpoochen: There must be some diff. How big is your project. If small and not confidential, export(right click project -> export) it and send to me at ysatso@gmail.com – Yogendra Singh Nov 17 '12 at 03:06
  • @McShpoochen Or try one other thing. Still copy those two files from working to non working. Once copied, right click your project and select `refresh`. In the end, do a clean build by `menu -> project>clean` and `menu -> project->build all`. – Yogendra Singh Nov 17 '12 at 03:23
  • @McShpoochen: Finally I got the issue. Your project is missing `project.properties` file in the root folder. This file contains information regarding android platform. Please copy that file from the working project and it should be fine. If required, I can export the fixed project and email back to you. – Yogendra Singh Nov 17 '12 at 15:56
  • I would really appreciate that. Also, thank you so much for all your help, you're truly kind. – McShpoochen Nov 17 '12 at 16:11
  • @McShpoochen: Done(sent the corrected project). Sometime it becomes difficult to find the problem with limited visibility of the problem. – Yogendra Singh Nov 17 '12 at 17:10
  • I'm terribly sorry, Yogendra, I imported what you sent me but the problem didn't go away. Maybe I'm missing components? – McShpoochen Nov 18 '12 at 01:07
  • @McShpoochen We need to verify the things now. Open Marker view(Menu -> Window -> Show view -> General -> Marker) and let me know now what error it's showing in the view(ignore the warnings for now). – Yogendra Singh Nov 18 '12 at 06:43
  • 1) Android target Problem (1 item) - Unable to resolve target 'android-16' 2) Faceted Project Problem (1 item) - Implementation of project facet java could not be found. Functionality will be limied. 3) Java Build Path Problems (1 item) - project 'Cookbook' is missing required library: C:\Documents and Settings\ysingh\android-sdks\platforms\android-16\android.jar' 4) Java Problems (1 item) - The project cannot be built until built path errors are resolved – McShpoochen Nov 18 '12 at 11:47
  • @McShpoochen: Sent another version in your email. Check it out. – Yogendra Singh Nov 18 '12 at 18:10
  • Same problem, Yogendra. Maybe I'm lacking several important JARs or something? I'm really clueless over this. – McShpoochen Nov 18 '12 at 20:31
  • @McShpoochen What all you see now in Marker view? – Yogendra Singh Nov 18 '12 at 21:44
  • 1) Android Target Problem (2 items): - Unable to resolve target 'android-14' - Unable to resolve 'android-14' until the SDK is loaded. 2) Java Problems (2 items): - The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project - The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files (Also another 12 Java Task, something with the TODO Auto-generated catch blocks, consctructor stubs and method stubs) – McShpoochen Nov 18 '12 at 22:08
  • @McShpoochen: Looks like your Android plugin is not installed correctly. Go to `Menu->Help->Install New Software`, add update site `https://dl.google.com/eclipse/plugin/4.2` and then select the site to install android plugins. Once done, restart the eclipse and check. If still it gives errors, share me the details. – Yogendra Singh Nov 19 '12 at 02:23
  • 1) Android Target Problem (1 item): - Unable to resolve target 'android-14' 2) Java Problems (2 items): - The project was not built since its build path is incomplete. Cannot find the class file for java.lang.Object. Fix the build path then try building this project - The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files (Also another 12 Java Task, something with the TODO Auto-generated catch blocks, consctructor stubs and method stubs) – – McShpoochen Nov 19 '12 at 16:12
  • @McShpoochen: I think you are close as there is only one issue left. Open `project.properties` file in your root folder "cookbook". In the end, update the platform to `16` as `target=android-16` and try. – Yogendra Singh Nov 19 '12 at 16:15
  • Now it says: 1) Unable to resolve target 'android-16' - Unable to resolve 'android-16' until the SDK is loaded. (Along with those other Java problems or whatnot) I really hate bothering you this much, would you suggest a some way of deletion of all records and download from scratch? It wouldn't be perfectly convenient to say the least, but if you think this is solvable I'd be even more greatful. – McShpoochen Nov 20 '12 at 01:39
  • @McShpoochen: Its definitely solvable. It works for me since day one. Can you please run your Android SDK Manager as : `Menu - Window -> Android SDK Manager` and make sure 4.2 SDK platform is showing as installed. If not, select the check box in front and install it. – Yogendra Singh Nov 20 '12 at 03:01
  • You were right, it wasn't installed. But will I be able to program and build applications for lower Android platforms as well? In other words, should I install every other API version or does API 17 cover them all? Edit: Looks like it's working! Thank you so very much. Should I install every other API version as well though? (I installed API 16 and 17) – McShpoochen Nov 20 '12 at 12:38
  • @McShpoochen: Finally!! Good to know, it worked! It's per your need. Feel free to install the lower versions. If you think this was helpful, don't forget to accept the answer. – Yogendra Singh Nov 20 '12 at 13:39
  • @McShpoochenL You still haven't accepted the answer. You should see an arrow sign next to the votes in front of the answer. You need to click that to accept the answer. If you don't accept, your question remains open which is not considered good practice here. – Yogendra Singh Nov 28 '12 at 20:10
0

Redownload the JDK, this will automatically update Eclipse.

Mordechai
  • 15,437
  • 2
  • 41
  • 82