title: Google Maps Android API V2 problems
body: <p>I'm trying to put together a working example of Google Maps Android API V2.  I have found four tutorials that describe how to do this (DJ-android, Vogella, 2 tutorials from official docs) and none of them work.  I have found nearly a dozen posts, like this one,  from as many other developers, with exactly the same problem: "Binary XML file line #x Error inflating class".  On stackoverflow, none of the dozen posts have a single accepted answer.  I know of no working examples of this API anywhere on the internet.</p>
  
  <p>The contents of my project are pasted below.  I think I have everything that has been recommended from all those various posts but, like so many others, I'm getting this inflation run time error.</p>
  
  <p>This actual project was taken from the Vogella tutorial which wouldn't even compile.  I applied fixes from other posts of the same problem.</p>
  
  <p>Can anyone tell me how to make this work?  Does anyone know of a working example anywhere?
  Thanks, Gary</p>
  
  <p>Manifest file...</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.mapdemo"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="17" /&gt;
  
          &lt;permission
          android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE"
          android:protectionLevel="signature" /&gt;
  
      &lt;uses-feature
          android:glEsVersion="0x00020000"
          android:required="true" /&gt;
  
      &lt;uses-permission android:name="com.vogella.android.locationapi.maps.permission.MAPS_RECEIVE" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.mapdemo.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;/activity&gt;
  
      &lt;/application&gt;
        &lt;meta-data
              android:name="com.google.android.maps.v2.API_KEY"
              android:value="I have a valid V2 key here" /&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>I have the Google Play services Library project in the workspace . . .
  <img src="https://i.stack.imgur.com/R1Aj1.png" alt="I copied the library project into my workspace"></p>
  
  <p>My main layout XML file . . .</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity" &gt;
  
  &lt;fragment
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.example.mapdemo.MainActivity"
      class="com.google.android.gms.maps.SupportMapFragment" /&gt;
  
  &lt;/RelativeLayout&gt; 
  </code></pre>
  
  <p>The MainActivity.java file . . . (wish the code paste worked on this forum)</p>
  
  <pre><code>package com.example.mapdemo;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  
  import android.support.v4.app.FragmentActivity;  
  import com.google.android.gms.maps.SupportMapFragment;  
  
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.MapFragment;
  import com.google.android.gms.maps.model.BitmapDescriptorFactory;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.Marker;
  import com.google.android.gms.maps.model.MarkerOptions;
  
  public class MainActivity extends android.support.v4.app.FragmentActivity {
    static final LatLng HAMBURG = new LatLng(53.558, 9.927);
    static final LatLng KIEL = new LatLng(53.551, 9.993);
    private GoogleMap map;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
          .getMap();
      Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
          .title("Hamburg"));
      Marker kiel = map.addMarker(new MarkerOptions()
          .position(KIEL)
          .title("Kiel")
          .snippet("Kiel is cool")
          .icon(BitmapDescriptorFactory
              .fromResource(R.drawable.ic_launcher)));
  
      // Move the camera instantly to hamburg with a zoom of 15.
      map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
  
      // Zoom in, animating the camera.
      map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
    }
  
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
  
      return true;
    }
  
  } 
  </code></pre>
  
  <p>the Logcat... (is there some secret to pasting this stuff?)</p>
  
  <pre><code>08-12 13:00:52.380: W/dalvikvm(8118): VFY: unable to resolve instance field 28
  08-12 13:00:52.550: W/dalvikvm(8118): Unable to resolve superclass of Lmaps/p/w; (734)
  08-12 13:00:52.550: W/dalvikvm(8118): Link of class 'Lmaps/p/w;' failed
  08-12 13:00:52.550: W/dalvikvm(8118): Unable to resolve superclass of Lmaps/ap/as; (6056)
  08-12 13:00:52.550: W/dalvikvm(8118): Link of class 'Lmaps/ap/as;' failed
  08-12 13:00:52.550: W/dalvikvm(8118): Unable to resolve superclass of Lmaps/af/k; (5085)
  08-12 13:00:52.550: W/dalvikvm(8118): Link of class 'Lmaps/af/k;' failed
  08-12 13:00:52.550: E/dalvikvm(8118): Could not find class 'maps.af.k', referenced from method maps.ag.an.a
  08-12 13:00:52.550: W/dalvikvm(8118): VFY: unable to resolve new-instance 4928 (Lmaps/af/k;) in Lmaps/ag/an;
  08-12 13:00:52.681: W/dalvikvm(8118): threadid=1: thread exiting with uncaught exception (group=0x40017560)
  08-12 13:00:52.691: E/AndroidRuntime(8118): FATAL EXCEPTION: main
  08-12 13:00:52.691: E/AndroidRuntime(8118): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapdemo/com.example.mapdemo.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.os.Handler.dispatchMessage(Handler.java:99)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.os.Looper.loop(Looper.java:130)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at java.lang.reflect.Method.invoke(Method.java:507)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at dalvik.system.NativeStart.main(Native Method)
  08-12 13:00:52.691: E/AndroidRuntime(8118): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:212)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.Activity.setContentView(Activity.java:1657)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.example.mapdemo.MainActivity.onCreate(MainActivity.java:26)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     ... 11 more
  08-12 13:00:52.691: E/AndroidRuntime(8118): Caused by: java.lang.RuntimeException: API key not found.  Check that &lt;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your API key"/&gt; is in the &lt;application&gt; element of AndroidManifest.xml
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at maps.ag.bb.a(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at maps.ag.bb.a(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at maps.ag.an.a(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at maps.ag.bi.a(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at maps.ag.bh.a(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at blf.onTransact(SourceFile:107)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.os.Binder.transact(Binder.java:279)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.google.android.gms.internal.bh$4.b(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.google.android.gms.internal.bh.a(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.google.android.gms.internal.bh.onCreateView(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
  08-12 13:00:52.691: E/AndroidRuntime(8118):     ... 20 more
  </code></pre>