Just follow The Links As its your first map application.
http://mobiforge.com/developing/story/developing-with-google-maps-v2-android Follow the link and check 1)make Sure U have google map v2 support library (Add android-support-v4) and
public class MainActivity extends FragmentActivity {
2)Check and modify the Manifest 3) In layout
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/crntlocation"
class="com.google.android.gms.maps.SupportMapFragment" />
4) In Activity
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
googleMap = fm.getMap();
It will solve your Problem.
You have to declare fragment class of map in your xml layout as below: Which is used to load the GoogleMap
in your fragment.
Have your referred Add a Map in your Application ?
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
EDITED:
The error is because your application contains the API level below 12 . And Please note that the code below is only useful for testing your settings in an application targeting Android API 12 or later, Below code should not be used in a production application.
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
So instead try as below:
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();