title: How to properly use the google maps fragment in a navigation drawer activity fragment
body: <p>I'm trying to put the Google Maps fragment in my app but I keep getting this error when I try to inflate the view in the Locations class:</p>
  <pre><code>android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class fragment
  Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class fragment
  Caused by: android.app.Fragment$InstantiationException: Trying to instantiate a class com.google.android.gms.maps.SupportMapFragment that is not a Fragment
  </code></pre>
  <hr />
  <p>I want to put the maps fragment in another fragment with is loaded in the main activity with the navigation drawer.</p>
  <p>Here is my code loading the locations fragment the map should go into:</p>
  <pre><code>@Override
      public boolean onNavigationItemSelected(MenuItem item) {
          // Handle navigation view item clicks here.
          int id = item.getItemId();
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  
          Fragment fragment = new Race();
          toolbar.setTitle(R.string.nav_name_race);
          FragmentManager fragmentManager = getFragmentManager();
  
          if (id == R.id.nav_race) {
              toolbar.setTitle(R.string.nav_name_race);
              fragment = new Race();
          } else if (id == R.id.nav_pilot) {
              toolbar.setTitle(R.string.nav_name_pilot);
              fragment = new Pilot();
          } else if (id == R.id.nav_locations) {
              toolbar.setTitle(R.string.nav_name_locations);
              fragment = new Locations();
          } else if (id == R.id.nav_channelpicker) {
              toolbar.setTitle(R.string.nav_name_channelpicker);
              fragment = new Channelpicker();
          } else if (id == R.id.nav_band_overview) {
              toolbar.setTitle(R.string.nav_name_band_overview);
              fragment = new BandOverview();
          }
  
          fragmentManager.beginTransaction()
                  .replace(R.id.mainframelayout, fragment)
                  .commit();
  
  
          DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
          drawer.closeDrawer(GravityCompat.START);
          return true;
      }
  </code></pre>
  <p>The Locations class:</p>
  <pre><code>public class Locations extends Fragment implements OnMapReadyCallback {
  
      private View view;
      private GoogleMap map;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          this.view = inflater.inflate(R.layout.content_locations, container, false);
          SupportMapFragment mapFragment = (SupportMapFragment) (((FragmentActivity) getActivity()).getSupportFragmentManager().findFragmentById(R.id.map));
          mapFragment.getMapAsync(this);
  
  
          //set fab onClickListener
          FloatingActionButton fabtop = (FloatingActionButton) view.findViewById(R.id.fabtop);
          assert fabtop != null;
          fabtop.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Toast.makeText(view.getContext(), &quot;top&quot;, Toast.LENGTH_SHORT).show();
              }
          });
  
          FloatingActionButton fabbottom = (FloatingActionButton) view.findViewById(R.id.fabbottom);
          assert fabbottom != null;
          fabbottom.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Toast.makeText(view.getContext(), &quot;bottom&quot;, Toast.LENGTH_SHORT).show();
              }
          });
  
          return this.view;
      }
  
      @Override
      public void onMapReady(GoogleMap googleMap)
      {
          map = googleMap;
  
          // Add a marker in Sydney and move the camera
          LatLng sydney = new LatLng(-34, 151);
          map.addMarker(new MarkerOptions().position(sydney).title(&quot;Marker in Sydney&quot;));
          map.moveCamera(CameraUpdateFactory.newLatLng(sydney));
      }
  }
  </code></pre>
  <p>And the layout file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:paddingTop=&quot;?android:attr/actionBarSize&quot;
      app:layout_behavior=&quot;@string/appbar_scrolling_view_behavior&quot;
      tools:context=&quot;.MainActivity&quot;&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id=&quot;@+id/fabtop&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_gravity=&quot;right|bottom&quot;
          android:src=&quot;@drawable/ic_menu_mylocation&quot;
          app:backgroundTint=&quot;#FFFFFF&quot;
          android:layout_above=&quot;@+id/fabbottom&quot;
          android:layout_alignParentRight=&quot;true&quot;
          android:layout_alignParentEnd=&quot;true&quot;
          android:layout_marginRight=&quot;@dimen/fab_margin&quot; /&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id=&quot;@+id/fabbottom&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_gravity=&quot;right|bottom&quot;
          android:src=&quot;@mipmap/ic_add_white_48dp&quot;
          android:layout_alignParentBottom=&quot;true&quot;
          android:layout_alignParentRight=&quot;true&quot;
          android:layout_alignParentEnd=&quot;true&quot;
          android:layout_margin=&quot;@dimen/fab_margin&quot; /&gt;
      
      &lt;fragment xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
          xmlns:tools=&quot;http://schemas.android.com/tools&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:id=&quot;@+id/map&quot;
          tools:context=&quot;.MapsActivity&quot;
          android:name=&quot;com.google.android.gms.maps.SupportMapFragment&quot; /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>I think the problem is having a fragment inside a fragment, because if I make a new Activity for the map everything works fine. I'm still a beginner in working with fragments and don't know the proper way to insert the maps fragment in my app.</p>
  <p>Every tip is appreciated.</p>