title: InflateException while trying to display a Google Map
body: <p>I'm getting mad about this problem! It has already been discussed many times but nothing seems to work for me. I'm just trying to display a map in my activity.
  Here are my files:<br><br>MapTest.java<br></p>
  
  <pre><code>package it.michele.pedometer;
  
  import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  
  public class MapTest extends FragmentActivity {
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.map_layout);
      }
  
  }
  </code></pre>
  
  <p><br>
  map_layout.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/map"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   class="com.google.android.gms.maps.SupportMapFragment"/&gt;&lt;br&gt;
  </code></pre>
  
  <p>manifest</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="it.michele.pedometer"
      android:installLocation="auto"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="18" /&gt;
  
      &lt;uses-feature
          android:glEsVersion="0x00020000"
          android:required="true" /&gt;
  
      &lt;permission
          android:name="it.michele.pedometer.permission.MAPS_RECEIVE"
          android:protectionLevel="signature" /&gt;
  
      &lt;uses-permission android:name="it.michele.pedometer.permission.MAPS_RECEIVE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&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.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/walking_man"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="it.michele.pedometer.Pedometer"
              android:label="@string/app_name"
              android:screenOrientation="portrait" &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;/activity&gt;
          &lt;activity
              android:name="it.michele.pedometer.MapTest"
              android:label="asd"
              android:screenOrientation="portrait" &gt;
          &lt;/activity&gt;
  
          &lt;meta-data
              android:name="com.google.android.maps.v2.API_KEY"
              android:value="myKey..." /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><br>I tried it on an emulator with API 16 and this is the LogCat:<br></p>
  
  <pre><code>09-11 20:33:41.319: E/AndroidRuntime(1017): FATAL EXCEPTION: main
  09-11 20:33:41.319: E/AndroidRuntime(1017): java.lang.RuntimeException: Unable to start activity ComponentInfo{it.michele.pedometer/it.michele.pedometer.MapTest}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.os.Handler.dispatchMessage(Handler.java:99)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.os.Looper.loop(Looper.java:137)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.ActivityThread.main(ActivityThread.java:4745)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at java.lang.reflect.Method.invokeNative(Native Method)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at java.lang.reflect.Method.invoke(Method.java:511)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at dalvik.system.NativeStart.main(Native Method)
  09-11 20:33:41.319: E/AndroidRuntime(1017): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.Activity.setContentView(Activity.java:1867)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at it.michele.pedometer.MapTest.onCreate(MapTest.java:12)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.Activity.performCreate(Activity.java:5008)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     ... 11 more
  09-11 20:33:41.319: E/AndroidRuntime(1017): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.Fragment.instantiate(Fragment.java:584)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.Fragment.instantiate(Fragment.java:552)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.Activity.onCreateView(Activity.java:4656)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     ... 20 more
  09-11 20:33:41.319: E/AndroidRuntime(1017): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     at android.app.Fragment.instantiate(Fragment.java:574)
  09-11 20:33:41.319: E/AndroidRuntime(1017):     ... 23 more
  </code></pre>
  
  <p>Any idea on how to solve the problem? Thank you!
  <br><br></p>
  
  <h1><strong>EDIT</strong></h1>
  
  <p>I made this changes:<br>
  I referenced the google-play-services.jar as an external jar<br>
  map_layout.xml<br></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:name="com.google.android.gms.maps.MapFragment"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  </code></pre>
  
  <p>MapTest.java<br></p>
  
  <pre><code>package it.michele.pedometer;
  
  import android.app.Activity;
  import android.os.Bundle;
  
  public class MapTest extends Activity {
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.map_layout);
      }
  
  }
  </code></pre>
  
  <p>LogCat<br></p>
  
  <pre><code>09-11 20:56:32.180: E/AndroidRuntime(1358): FATAL EXCEPTION: main
  09-11 20:56:32.180: E/AndroidRuntime(1358): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.Activity.onCreateView(Activity.java:4663)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.Activity.setContentView(Activity.java:1867)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at it.michele.pedometer.MapTest.onCreate(MapTest.java:12)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.Activity.performCreate(Activity.java:5008)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.os.Handler.dispatchMessage(Handler.java:99)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.os.Looper.loop(Looper.java:137)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at android.app.ActivityThread.main(ActivityThread.java:4745)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at java.lang.reflect.Method.invokeNative(Native Method)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at java.lang.reflect.Method.invoke(Method.java:511)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  09-11 20:56:32.180: E/AndroidRuntime(1358):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I don't know what to do...</p>