TJ1 TJ1 - 3 months ago 18
Java Question

Error in Eclipse (for Android): The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files

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.

Answer

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.