title: I can't get Google Maps Android API v2 to work : GoogleMap cannot be resolved to a type
body: <p>I -think I- have done all the steps in these two links :</p>
  <p><a href="http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/" rel="nofollow noreferrer">http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/</a>
  <a href="http://developer.android.com/google/play-services/setup.html" rel="nofollow noreferrer">http://developer.android.com/google/play-services/setup.html</a></p>
  <p>so please don't send them as answers.</p>
  <p>I have downloaded the Maps API, copied it into Eclipse Workspace, marked it as library, referenced it in my project. But no success. I'm still getting the errors :</p>
  <blockquote>
  <p>GoogleMap cannot be resolved to a type</p>
  <p>MapFragment cannot be resolved to a type</p>
  </blockquote>
  <p>Here's my MainActivity.Java:</p>
  <pre><code>package com.mapsapp.mapsappv1;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.Toast;
  
  
  public class MainActivity extends Activity {
   
      
      // Google Map
      private GoogleMap googleMap;
   
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          
          
   
          try {
              // Loading map
              initilizeMap();
   
          } catch (Exception e) {
              e.printStackTrace();
          }
   
      }
   
      /**
       * function to load map. If map is not created it will create it for you
       * */
      private void initilizeMap() {
          if (googleMap == null) {
              googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
   
              // check if map is created successfully or not
              if (googleMap == null) {
                  Toast.makeText(getApplicationContext(),
                          &quot;Sorry! unable to create maps&quot;, Toast.LENGTH_SHORT)
                          .show();
              }
          }
      }
   
      @Override
      protected void onResume() {
          super.onResume();
          initilizeMap();
      }
   
  }
  </code></pre>
  <p>And here is my AndroidManifest.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.mapsapp.mapsappv1&quot;
      android:versionCode=&quot;1&quot;
      android:versionName=&quot;1.0&quot; &gt;
  
  &lt;permission
          android:name=&quot;com.mapsapp.mapsappv1.permission.MAPS_RECEIVE&quot;
          android:protectionLevel=&quot;signature&quot; /&gt;
  
  &lt;uses-permission android:name=&quot;com.mapsapp.mapsappv1.permission.MAPS_RECEIVE&quot; /&gt;
  
      &lt;uses-sdk
          android:minSdkVersion=&quot;12&quot;
          android:targetSdkVersion=&quot;18&quot; /&gt;
  
  
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
      &lt;uses-permission android:name=&quot;com.google.android.providers.gsf.permission.READ_GSERVICES&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot; /&gt;
   
      &lt;!-- Required to show current location --&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; /&gt;
      &lt;uses-permission android:name=&quot;android.permission.ACCESS_FINE_LOCATION&quot; /&gt;
   
      &lt;!-- Required OpenGL ES 2.0. for Maps V2 --&gt;
      &lt;uses-feature
          android:glEsVersion=&quot;0x00020000&quot;
          android:required=&quot;true&quot; /&gt;
  
       
  
      &lt;application
          android:allowBackup=&quot;true&quot;
          android:icon=&quot;@drawable/ic_launcher&quot;
          android:label=&quot;@string/app_name&quot;
          android:theme=&quot;@style/AppTheme&quot; &gt;
          
          &lt;!-- this line is part of my trials.. probably unnecessary : --&gt;
          &lt;activity android:name=&quot;com.google.android.gms.UnusedStub&quot; /&gt;
          
          &lt;activity
              android:name=&quot;com.mapsapp.mapsappv1.MainActivity&quot;
              android:label=&quot;@string/app_name&quot; &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          
          
          &lt;!-- Google Maps API Key --&gt;
  &lt;meta-data
       android:name=&quot;com.google.android.maps.v2.API_KEY&quot;
       android:value=&quot;myApiKeyGeneratedWithSHA1Key-ItShouldBeTrue&quot; /&gt;
       
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  <p>Maybe somebody had this error and knows how to solve it ?</p>
  <p>and I have tried restarting eclipse, cleaning the project, creating the project from scratch (its actually v10 or something :) ) apparently I'm doing something wrong..</p>
  <p>Any kind of help will be appreciated. But please don't paste the two links I have mentioned at the beginning.</p>
  <h2>Edit: Progress Report</h2>
  <p>@regeme's comment : <code>import com.google.android.gms.maps.GoogleMap;</code> helped getting rid of the error : <code>GoogleMap cannot be resolved to a type</code></p>
  <p>However, MapFragment error remains.</p>
  <p>I have changed the code according @Imtiyaz Khalani's answer. The new code is this :</p>
  <pre><code>private void initilizeMap() {
          if (mMap == null) {
              //googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
              mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
              // check if map is created successfully or not
              if (mMap == null) {
                  Toast.makeText(getApplicationContext(),
                          &quot;Sorry! unable to create maps&quot;, Toast.LENGTH_SHORT)
                          .show();
              }
          }
      }
  </code></pre>
  <p>But it gives the error : <code>The method getSupportFragmentManager() is undefined for the type MainActivity</code></p>