I am trying to run an Android project that someone else has created. I have opened the project in Eclipse as:
File --> New --> Project --> Android Project from existing code
Here are the first two lines of one of Java files:
package aa.bb.cc;
import java.io.File;
There is red cross sign at the beginning of these lines and when I hold the mouse over them I get this message for the first line: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
anfd for the second line get this message: The import java.net cannot be resolved
.
What is the reason and how can I resolve these error messages?
Thanks.
Java is a case-sensitive language, that is, uppercase and lowercase letters are treated differently. Here “string” is not resolved because there is no class or data type named “string”.
You have open eclipse. ini file and change -vm path to correct JDK location. In my case it's /Library/Java/JavaVirtualMachines/jdk1.
Do one more step before running:
Right Click(Project) -> Properties -> Java Build Path -> Libraries ->
Add Library -> Select the Java Library
Click OK and then clean-build (Project -> Clean
& Project -> Build All
or Ctrl+B
) your project. It should be fine.
This is an annoying Eclipse Bug which seems to bite now and then. See http://dev-answers.blogspot.de/2009/06/eclipse-build-errors-javalangobject.html for a possible solution, otherwise try the following;
Close the project and reopen it.
Clean the project (It will rebuild the buildpath hence reconfiguring with the JDK libraries)
OR
Delete and Re-import the project and if necessary do the above steps again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With