title: Getting error "java.lang.RuntimeException: Unable to start activity" in my app
body: <p>My application worked yesterday, I cant figure out why it stopped working. The only thing I tried doing was to create a signed apk. to do this I had to create a new Google maps key and place it into the manifest file. I done this following the Google developers tutorial. But now when I try to run the app it start up, I click a button and it force closes.</p>
  
  <p>This is the error log:</p>
  
  <pre><code>  03-20 23:31:33.636  10036-10036/project.sharethefare E/AndroidRuntime﹕ FATAL EXCEPTION: main
          Process: project.sharethefare, PID: 10036
          java.lang.RuntimeException: Unable to start activity ComponentInfo{project.sharethefare/project.sharethefare.CurrentLocation}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
                  at android.app.ActivityThread.access$900(ActivityThread.java:172)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:145)
                  at android.app.ActivityThread.main(ActivityThread.java:5834)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
           Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:770)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
                  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:428)
                  at android.app.Activity.setContentView(Activity.java:2241)
                  at project.sharethefare.CurrentLocation.onCreate(CurrentLocation.java:24)
                  at android.app.Activity.performCreate(Activity.java:6221)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
                  at android.app.ActivityThread.access$900(ActivityThread.java:172)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:145)
                  at android.app.ActivityThread.main(ActivityThread.java:5834)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
           Caused by: java.lang.RuntimeException: The API key can only be specified once. It is recommended that you use the meta-data tag with the name: com.google.android.maps.v2.API_KEY in the &lt;application&gt; element of AndroidManifest.xml
                  at com.google.maps.api.android.lib6.gmm6.c.g.a(Unknown Source)
                  at com.google.maps.api.android.lib6.c.i.a(Unknown Source)
                  at com.google.maps.api.android.lib6.c.el.a(Unknown Source)
                  at com.google.maps.api.android.lib6.c.ab.a(Unknown Source)
                  at com.google.maps.api.android.lib6.c.aa.a(Unknown Source)
                  at com.google.android.gms.maps.internal.x.onTransact(SourceFile:107)
                  at android.os.Binder.transact(Binder.java:380)
                  at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
                  at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
                  at com.google.android.gms.dynamic.a$4.b(Unknown Source)
                  at com.google.android.gms.dynamic.a.a(Unknown Source)
                  at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
                  at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
                  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:920)
                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
                  at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1206)
                  at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2159)
                  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
                  at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
                  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:428)
                  at android.app.Activity.setContentView(Activity.java:2241)
                  at project.sharethefare.CurrentLocation.onCreate(CurrentLocation.java:24)
                  at android.app.Activity.performCreate(Activity.java:6221)
                  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2725)
                  at android.app.ActivityThread.access$900(ActivityThread.java:172)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:145)
                  at android.app.ActivityThread.main(ActivityThread.java:5834)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at java.lang.reflect.Method.invoke(Method.java:372)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
  </code></pre>
  
  <p>This is the CurrentLocation class:</p>
  
  <pre><code>    package project.sharethefare;
  
  import android.content.Intent;
  import android.support.v4.app.FragmentActivity;
  import android.os.Bundle;
  
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.SupportMapFragment;
  import com.google.android.gms.maps.model.LatLng;
  
  
  import android.location.Location;
  import android.view.View;
  
  public class CurrentLocation extends FragmentActivity {
  
      private GoogleMap mMap; // Might be null if Google Play services APK is not available.
      //________________________________________________________________________________________
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {        //auto generated
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_current_location);
          setUpMapIfNeeded();                                     //part of google maps api
          mMap.setMyLocationEnabled(true);                               //creates a new HomeScreen
      }
  
  
      @Override
      protected void onResume() {                             //Auto Generated
          super.onResume();
          setUpMapIfNeeded();                                 //set up map if not already created
      }
  
      /**
       * Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly
       * installed) and the map has not already been instantiated.. This will ensure that we only ever
       * call {@link #setUpMap()} once when {@link #mMap} is not null.
       * &lt;p/&gt;
       * If it isn't installed {@link SupportMapFragment} (and
       * {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to
       * install/update the Google Play services APK on their device.
       * &lt;p/&gt;
       * A user can return to this FragmentActivity after following the prompt and correctly
       * installing/updating/enabling the Google Play services. Since the FragmentActivity may not
       * have been completely destroyed during this process (it is likely that it would only be
       * stopped or paused), {@link #onCreate(Bundle)} may not be called again so we should call this
       * method in {@link #onResume()} to guarantee that it will be called.
       */
      private void setUpMapIfNeeded() {
          // Do a null check to confirm that we have not already instantiated the map.
          if (mMap == null) {
              // Try to obtain the map from the SupportMapFragment.
              mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.curLocMap))
                      .getMap();
              // Check if we were successful in obtaining the map.
              if (mMap != null) {
                  setUpMap();
              }
          }
      }
  
      /**
       * This is where we can add markers or lines, add listeners or move the camera. In this case, we
       * just add a marker near Africa.
       * &lt;p/&gt;
       * This should only be called once and when we are sure that {@link #mMap} is not null.
       */
      //call the method to continuously check current location
      private void setUpMap() {
          mMap.setOnMyLocationChangeListener(myLocationChangeListener);
      }
  
      //called above. Used to constantly update the users position on the map
      private GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
          @Override
          public void onMyLocationChange(Location location) {
              //create a new latitude and longitude point
              LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());
              //make global variables on home screen == to current location
              HomeScreen.curLat = location.getLatitude();
              HomeScreen.curLong = location.getLongitude();
              HomeScreen.curLocSet = true;
              //animate the camera to zoom in on position when found
              mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(loc, 16.0f));
          }
      };
  
      public void backToHome(View view){ // called when button clicked. returns to homeScreen activity
          Intent intent = new Intent(CurrentLocation.this,HomeScreen.class);
          startActivity(intent);
      }
  
  }
  </code></pre>
  
  <p>This is the corresponding xml file:</p>
  
  <pre><code>    &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:gravity="center"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:background="#000"&gt;
  
      &lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
  
          android:layout_marginTop="60dp"
          android:layout_marginBottom="50dp"
          android:layout_height="wrap_content"
          android:layout_width="match_parent"
          android:id="@+id/curLocMap"
          tools:context="project.sharethefare.CurrentLocation"
          android:name="com.google.android.gms.maps.SupportMapFragment"/&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="50dp"
          android:layout_marginLeft="30dp"
          android:layout_marginRight="30dp"
          android:layout_marginBottom="70dp"
          android:text="@string/set_Cur_Loc"
          android:textSize="20sp"
          android:onClick="backToHome"
          android:background="@drawable/button_design"
          android:textStyle="bold"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And this is the 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="project.sharethefare" &gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&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-feature
          android:glEsVersion="0x00020000"
          android:required="true" /&gt;
      &lt;!--
   The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
           Google Maps Android API v2, but are recommended.
      --&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=".HomeScreen"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version" /&gt;
          &lt;meta-data
              android:name="com.google.android.maps.v2.API_KEY"
              android:value="" /&gt;
  
          &lt;activity
              android:name=".CurrentLocation"
              android:label="@string/title_activity_current_location" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".Destination"
              android:label="@string/title_activity_maps" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".Share"
              android:label="@string/title_activity_share" &gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".SplashScreen"
              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;meta-data
              android:name="com.google.android.geo.API_KEY"
              android:value=""/&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>