title: Google Maps API V2 crash - FATAL EXCEPTION
body: <p>I've tried a tutorial to implement a Google Maps in my application.
  <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></p>
  
  <p>I would try the example, but it is crashing at this level : <code>setContentView(R.layout.activity_main);</code></p>
  
  <p>I correctly follow the tuto, and normally there is no API Key problem.</p>
  
  <p><strong>EDIT : Here is all my solved code - Errors are shown in comment</strong></p>
  
  <p><strong>MANIFEST.XML :</strong></p>
  
  <pre><code>     &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.essaimap"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;permission
          android:name="com.example.essaimap.permission.MAPS_RECEIVE"
          android:protectionLevel="signature" /&gt;
  
      &lt;uses-permission android:name="com.example.essaimap.permission.MAPS_RECEIVE" /&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="16" /&gt;
  
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
      &lt;!-- Required to show current location --&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  
      &lt;!-- Required OpenGL ES 2.0. for Maps V2 --&gt;
      &lt;uses-feature
          android:glEsVersion="0x00020000"
          android:required="true" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
  
          &lt;!-- IMPORTANT ! DO NOT FORGET THIS META-DATA !!! --&gt;
          &lt;meta-data 
              android:name="com.google.android.gms.version" 
              android:value="@integer/google_play_services_version" /&gt;
          &lt;!-- IMPORTANT ! DO NOT PUT THIS META IN ACTIVITY ELEMENT--&gt;
          &lt;meta-data 
                  android:name="com.google.android.maps.v2.API_KEY"
                  android:value="AIzaSyDWCZGT4OIUAZEOUIYAZEOIYAZOEIYAZOEIY6WRvbh6BnHSAipgg" /&gt;
  
          &lt;activity
              android:name="com.example.essaimap.MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
              &lt;!-- I put my meta here, that is why my app was crashing 
              &lt;meta-data 
                  android:name="com.google.android.maps.v2.API_KEY"
                  android:value="AIzaSyDWCZGT4n2HLZ5bUCM6WRvbh6BnHSAipgg" /&gt; --&gt;            
          &lt;/activity&gt;
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>ACTIVITY_MAIN.XML :</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" &gt;
  
      &lt;fragment
          android:id="@+id/map"
          android:name="com.google.android.gms.maps.MapFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>MAINACTIVITY.JAVA :</strong></p>
  
  <pre><code>    public class MainActivity extends FragmentActivity // Not ACTIVITY
  {
      // Google Map
      private GoogleMap googleMap;
  
      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(),"Sorry! unable to create maps",Toast.LENGTH_SHORT).show();
              }
          }
      }
  
      protected void onResume() 
      {
          super.onResume();
          initilizeMap();
      }
  }
  </code></pre>
  
  <p><strong>LOGCAT</strong>
  <img src="https://i.stack.imgur.com/LfBFX.png" alt="My Application&#39;s error"></p>
  
  <p>My problem was solved thanks to @Piyush Gupta, @fasteque, @WarrenFaith, @Sankar V and @ViragBrahme. </p>
  
  <p>Tofuw</p>