简体   繁体   中英

The import com.google cannot be resolved

I am trying to do a Map View in android (migrating from iOS). In the android SDK pannel I have google APIs (API 17) installed, which I was hoping would fix the problem. So in my source code I have:

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

And its giving me the error: The import com.google cannot be resolved . I have searched google for a result, but they havent worked (most of them were making sure the Google API is installed.

I am on a Macbook Pro, 64 bit using Eclipse ADT downloaded from the android dev site.

In the AndroidManifest.xml file I have:

<uses-library android:name="com.google.android.maps" />

You have to add the library to your project.

You can find the .jar file in your sdk sdk\\add-ons\\addon-google_apis-google-17\\libs\\maps.jar

Thread about how to add a library in your android project : Adding a library/JAR to an Eclipse Android project

You also need to set the build target (Project > Properties > Android) to be a build target that has the Google APIs in it, to use Maps V1.

That being said, Raghunandan is correct -- you should be using Maps V2, as you can no longer get Maps V1 API keys. Note that Maps V2 does not require you to have a "Google APIs" build target.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM