title: Google Maps API v2 not working
body: <p>I am trying to build an application using Google Maps API v2 but the thing is, the application keeps giving me force closes although i followed all the required instructions. </p>
  
  <p>Here is the android part</p>
  
  <pre><code>import android.support.v4.app.FragmentActivity;
  import com.google.android.maps.GeoPoint;
  import com.google.android.maps.MapController;
  import com.google.android.maps.MapView;
  
  public class GPSonMap extends FragmentActivity{
  
   MapView map;
   MapController controller;
   LocationManager locationManager;
   LocationListener listener;
   PendingIntent pendingIntent ;
   Criteria criteria;
   MapOverlay overlay;
  
  
  @Override
  public void onCreate(Bundle onsaved)
  {
      super.onCreate(onsaved);
      setContentView(R.layout.map);
      Log.d("", "entered");
  
  
      map = (MapView)findViewById(R.id.mapView);
      }
  </code></pre>
  
  <p>and here is the XML </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=".MapsActivity" &gt;
  
  &lt;fragment
  
      class="com.google.android.gms.maps.SupportMapFragment"
      android:id="@+id/mapView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
  /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and this is my 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="com.bachelor.bond"
          android:versionCode="1"
          android:versionName="1.0" &gt;
  
          &lt;uses-sdk
              android:minSdkVersion="14"
              android:targetSdkVersion="17" /&gt;
        &lt;!--   &lt;permission
                android:name="com.example.example.permission.MAPS_RECEIVE"
                android:protectionLevel="signature"/&gt;
              &lt;uses-permission android:name="com.bachelor.bond.permission.MAPS_RECEIVE"/&gt;. --&gt;
  
             &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
           &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
          &lt;permission android:name="com.example.example.permission.C2D_MESSAGE" android:protectionLevel="signature" /&gt;
      &lt;uses-permission android:name="com.example.example.permission.C2D_MESSAGE" /&gt; 
  
      &lt;!-- App receives GCM messages. --&gt;
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
      &lt;!-- GCM connects to Google Services. --&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.READ_PHONE_STATE"/&gt; 
      &lt;!-- GCM requires a Google account. --&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;!-- Keeps the processor from sleeping when a message is received. --&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK"
           /&gt;
      &lt;uses-permission android:name="com.example.example.permission.MAPS_RECEIVE"/&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
        &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;  
      &lt;!-- Permission to vibrate --&gt;
          &lt;uses-permission android:name="android.permission.VIBRATE"/&gt;
          &lt;uses-permission android:name = "android.permission.ACCESS_FINE_LOCATION"/&gt;
  
          &lt;permission 
          android:name="com.example.example.permission.MAPS_RECEIVE" 
          android:protectionLevel="signature"&gt;&lt;/permission&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"&gt;
              &lt;uses-library android:name="com.google.android.maps" /&gt;
               &lt;activity
                  android:name=".GPSonMap"
                  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;uses-library android:name="com.google.android.maps" /&gt;
               &lt;intent-filter&gt;
          &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
          &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
          &lt;category android:name="com.example.example" /&gt;
        &lt;/intent-filter&gt;
                &lt;receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" 
                   android:permission="com.google.android.c2dm.permission.SEND" &gt;
  
      &lt;/receiver&gt;
       &lt;service android:name=".GCMIntentService" /&gt;
       &lt;activity android:name="Login"&gt;&lt;/activity&gt;
  
       &lt;meta-data
          android:name="com.google.android.maps.v2.API_KEY"
          android:value="****"/&gt;
  
          &lt;/application&gt;
  
      &lt;/manifest&gt;
  </code></pre>
  
  <p>And the Log Cat output</p>
  
  <pre><code>02-15 00:42:35.257: E/AndroidRuntime(2693): FATAL EXCEPTION: main
  02-15 00:42:35.257: E/AndroidRuntime(2693): java.lang.RuntimeException: Unable to start         activity ComponentInfo{com.bachelor.bond/com.dxample.example.GPSonMap}:     android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.os.Handler.dispatchMessage(Handler.java:99)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.os.Looper.loop(Looper.java:137)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.ActivityThread.main(ActivityThread.java:5039)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at java.lang.reflect.Method.invoke(Method.java:511)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at dalvik.system.NativeStart.main(Native Method)
  02-15 00:42:35.257: E/AndroidRuntime(2693): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.Activity.setContentView(Activity.java:1881)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at com.bachelor.bond.GPSonMap.onCreate(GPSonMap.java:54)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.Activity.performCreate(Activity.java:5104)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     ... 11 more
  02-15 00:42:35.257: E/AndroidRuntime(2693): Caused by:         android.support.v4.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
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     ... 21 more
  02-15 00:42:35.257: E/AndroidRuntime(2693): Caused by: java.lang.ClassNotFoundException:     Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path:     /system/framework/com.google.android.maps.jar:/data/app/com.bachelor.bond-1.apk
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
  02-15 00:42:35.257: E/AndroidRuntime(2693):     ... 24 more
  </code></pre>
  
  <p>One other problem I face, is that when i try to<br>
   <code>import com.google.android.gms.maps.MapFragment;</code>
  it gives an error that it doesnt recognise a package name to be <code>com.google.android.gms</code> so i cant even use the <code>GoogleMap</code>or <code>MapFragment</code> for example. </p>
  
  <p>So does anyone have any solution to those 2 problems? </p>