1

I try to show a google map to location that it it latitude&longitude is +34° 6' 46.53", +35° 39' 1.04 and I build this code

public class conactus extends Activity {

//instance variables for Marker icon drawable resources
private int userIcon;

//the map
private GoogleMap theMap;

//user marker
private Marker userMarker;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_connectus);

    //get drawable IDs
    userIcon = R.drawable.yellow_point;
    //find out if we already have it
    if(theMap==null){
        //get the map
        theMap = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
        //check in case map/ Google Play services not available
        if(theMap!=null){
            //ok - proceed
            theMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
            //update location
            updatePlaces();

        }

    }
}

private void updatePlaces(){

    //get last location
    double lat = 34.112924;
    double lng = 35.650288;
    //create LatLng
    LatLng lastLatLng = new LatLng(lat, lng);

    //remove any existing marker
    if(userMarker!=null) userMarker.remove();
    //create and set marker properties
    userMarker = theMap.addMarker(new MarkerOptions()
    .position(lastLatLng)
    .title("You are here")
    .icon(BitmapDescriptorFactory.fromResource(userIcon))
    .snippet("Your last recorded location"));
    //move to location
    theMap.animateCamera(CameraUpdateFactory.newLatLng(lastLatLng), 3000, null);
}

}

but when i run application on real device and after i active google play services on device i got non shown map with logcat

09-06 16:13:30.609: I/Google Maps Android API(18952): Failed to contact Google servers. Another attempt will be made when connectivity is established.
09-06 16:13:30.629: E/Google Maps Android API(18952): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71
DoctorDoom
  • 501
  • 2
  • 8
  • 21

1 Answers1

1

1. Try by adding following Permission

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

2. After changing API key in AndroidManifest.xml Must Clear Application Data

To Clear Application Data :

Either Go to Settings>Application Manager>Select Your Application > Click on Clear Data

Or Must Uninstall The Application before installing it ! Note Don't Re-install unless you Completely Uninstall the Application in order to clear its Data completely

Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71