Google Map API v2 is not showing Map on device

try to add

GoogleMap googleMap =    ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();

and replace your xml with

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"
/>

you have added the following code outside application tag instead put it inside the tag

<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />

<permission
    android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

hope this might help someone who is facing the same problem


May be this problem with API key or you just check your SHA1 fingerprint in your project api console(https://console.developers.google.com/project) and your eclipse Windows -> Preferences -> Android -> Build are same, other wise just update the SHA1 from console to build path or vice versa.


Use Fragment activity

eg:

public class Maps extends FragmentActivity {
    GoogleMap map;
    double lat;
    double lan;
    boolean flag = false;

    // private LocationManager lm;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mapptry);

        map = ((SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map)).getMap();
                 }
  }

Change ur map.xml to

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="wrap_content"
    android:layout_height="match_parent" />

EDIT

Got to do this also

import android.support.v4.app.FragmentActivity;

Before you do this Right click project->properties->buildpath->java build path -> libraries .. then click on add external jars

the go to

user\android-sdks\extras\android\support\v4

and select android-support-v4.jar

PS: Do all this provided your API key is correct . If you API key is wrong then also it shows only a white screen