0

Currently I am working on Google Maps and for creating that I followed all instructions in the android developers site. But I cant load map in my device, but I can point various places and all. Will my device support Google API V2? Is there any way to view map on my device? My device version is 2.3.3.

svs
  • 377
  • 9
  • 21

1 Answers1

1

I have a working GoogleMaps v2 application and initially I had the same issues that you describe. The problem in my case was that the API key I used was not matching the certificate I used to sign the application (debug/dev for the development phase and release for the Play released app). The application is working on all Android versions from 10 and on (so it works on 2.3.3). From the log error it sssems you may be having a connectivity issue. Did you declare the appropriate uses permissions? It should be:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Here is a short snippet of the main map code:

public class LocationActivity extends MapActivity {


    private MapController mapController;
    private MapView mapView;
    private LocationManager locationManager;
    private MyLocationOverlay myLocationOverlay;

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if(Utils.isRelease(getApplicationContext())) {
            setContentView(R.layout.location_activity_release); // bind the layout to the activity
        } else {
            setContentView(R.layout.location_activity); // bind the layout to the activity
        }

        // Configure the Map
        mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        mapView.setSatellite(false);
        mapController = mapView.getController();
        mapController.setZoom(15); // Zoon 1 is world view

        myLocationOverlay = new MyLocationOverlay(this, mapView);
        mapView.getOverlays().add(myLocationOverlay);
        // More map configurations follow...

And the layouts (notice the difference in the maps API key): location_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:apiKey="@string/google_maps_v1_api_key"
    android:clickable="true" /> 

And (location_activity_release.xml):

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:apiKey="@string/google_maps_v1_api_key_release"
    android:clickable="true" /> 
  • How to get that v1 api key? I don't have it with me,only have that v2 api key. – svs Jul 24 '13 at 04:58
  • Are you using "google_maps_v1_api_key" in your project? Is there any way to check app using v2 api key on device having lower versions? – svs Jul 24 '13 at 05:20