title: Android cannot find symbol method getMap()
body: <p>I have a gps app that works fine on my phone. However, I see there were people having a null pointer exception in the production.</p>
  
  <pre><code>    SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
  
      // Getting GoogleMap object from the fragment
      googleMap = fm.getMap();
  
      // Enabling MyLocation Layer of Google Map
      googleMap.setMyLocationEnabled(true);
  
      googleMap.setPadding(0, 0, 0, 90);
  </code></pre>
  
  <p>The error I'm getting from production is 
  Caused by:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(boolean)' on a null object reference
  </code></pre>
  
  <p>So I did some research and find out that getMap method has been removed and people recommend using <code>getMapAsync(this);</code></p>
  
  <pre><code>@Override
  public void onMapReady(GoogleMap googleMap) {
      this.googleMap = googleMap;    //which doesn't seem to work
  }
  </code></pre>
  
  <p>However, I'm referencing the <code>googleMap</code> variable in many different methods, and I cannot move all the code to <code>onMapReady</code> method. I tried using <code>this.googleMap = googleMap</code> inside the <code>onMapReady</code> method, but I'm still getting null pointer exceptions whenever I try to reference the <code>googleMap</code> variable. I defined the getMapAsync(this) in onCreated(), and then try to access the 'googleMap' object in onResume() and getting the null pointer exception. Is there a way to fix this?  Thank you.</p>