Eclipse not Recognizing any imports

2019-06-22 06:17发布

问题:

I seem to have botched up something in Eclipse. It isn't recognizing any of the libraries that I am trying to import.

Here are some of the things not being recognized:

import java.util.ArrayList;
import android.content.Intent;
import com.google.android.maps.MapView;

This is a open source project that I downloaded and then imported into Eclipse. I think I also downloaded the google apis the wrong way because things like MapView don't work in my other projects as well. Can someone please help me out?

Best,

Aneem

EDIT:

Fixed, most of the issues. Did it by hovering mouse to import line and clicking "Fix project setup..."

Now the only thing I have to do is get the google map related API to work.

回答1:

To check if you have properly installed ADT goto -> Window -> Preferences. If you see Android (in the preferences), it means you have ADT installed.

To point to the valid SDK directory, click on Android. Specify the location in the SDK location.

Even if you have correctly installed ADT and SDK, there is a chance that eclipse may not recognize as the Android project if you import it(depends on the project & files). Best thing is, to create a new Android project and copy the files from the imported project to the newly created Android project. This will definitely work.



回答2:

Two things to consider:

  1. open project properties -> Android section -> see if Android SDK is selected or not. if no SDK is selected just check it.

  2. in project properties -> Java Compiler section -> change "Compiler compliance level" to "1.6". This is because your have installed JDK 1.7 that has some problems with some packages!



回答3:

Most likely your ADT plugin is not pointing to the Android SDK. Follow the instructions for installing and configuring the plugin:

http://developer.android.com/sdk/eclipse-adt.html



回答4:

I right clicked on the project and selected properties and added Google APIs 2.3.3 as the target and did a project->clean and was able to launch the application. Many thanks.