title: getSupportFragmentManager().findFragmentById returns null for google maps in fragment in android?
body: <p>I have a problem with Google Maps, i.e. getSupportFragmentManager().findFragmentById returns always null. Do you have an idea how to solve this?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>fragment_map.xml:
  
  &lt;FrameLayout 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="com.myapp.something.MapFragment"&gt;
  &lt;fragment
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      class="com.google.android.gms.maps.SupportMapFragment" /&gt;                  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>MapsFragment.java:</p>
  
  <pre><code>public class MapFragment extends Fragment implements OnMapReadyCallback, android.location.LocationListener
  
  public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      SupportMapFragment mapFragment = (SupportMapFragment) this.getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
      mapFragment.getMapAsync(this);
  ...
  </code></pre>
  
  <p>I have Google Maps in Activity and it works with code:</p>
  
  <pre><code>SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                  .findFragmentById(R.id.map);
          mapFragment.getMapAsync(this);
  </code></pre>
  
  <p>I am trying to reuse this in fragment, becouse I need maps in fragment, not in activity, but it doesn't work.</p>
  
  <p>I tried:</p>
  
  <ul>
  <li>calling this code in "onCreateView" function</li>
  <li><code>SupportMapFragment mapFragment = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.map);</code></li>
  <li><code>GoogleMap mGoogleMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)).getMap();</code> is deprecated, and application crashes</li>
  <li><code>SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);</code>
  and similar variations, but in all cases I get null for mapFragment.</li>
  </ul>
  
  <p>Do you know how could I solve this problem? </p>