问题
I'm new to Google Maps inside an Android app and I'm trying to test the example that is included in the documentation: https://developers.google.com/maps/documentation/android/
I did some research and apparently this was included in the latest Google Play Services package. I really think I have the last one, but I still cannot resolve OnMapReadyCallback. This is how it looks:


Does anybody know what I could be missing?
Thanks
回答1:
Probably you need to change to Google APIs, go to properties
-> Android
.

So you will solve the problem implementing the class OnMapReadyCallback
:
import com.google.android.gms.maps.OnMapReadyCallback;
public class MapPane extends Activity implements OnMapReadyCallback {
You need to read all the info related to Google Maps Android API V2:
https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2
You need to create and API project and get the API key to work with Maps.
UPDATE:
probably you have an older version of the support library, so delete the current and import the last one, you can use the .jar in your project (located in: sdk\extras\android\support\v7
) or you can import the library project located in:
sdk\extras\android\support\v7\appcompat
.
回答2:
I had this problem too. Way back when I had imported the Google Play Services library into my workspace, I must have checked the box to "Copy projects into workspace". Thus, even though I updated the Google Play Services library with the SDK Manager, the library in my workspace was still the old version. Once I deleted the local version and imported the version from my "android-sdks" folder (without copying this time, of course), Eclipse could find the OnMapReadyCallback class.
回答3:
Add
compile 'com.google.android.gms:play-services:8.4.0'
to the dependencies in your build.gradle.
来源:https://stackoverflow.com/questions/28755174/onmapreadycallback-cannot-be-resolved-to-a-type