title: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.moveCamera on a null object reference
body: <p>i'm beginner, i want to develop a Google map Application in which i can search and select a place from autocomplete search , but when i click on any place then my App crash and display this error in the logcat please any one help me,</p>
  
  <p>MainActivity Code</p>
  
  <pre><code>    @Override
      protected void onPostExecute(String result) {
          super.onPostExecute(result);
  
          switch(downloadType){
              case PLACES:
                  // Creating ParserTask for parsing Google Places
                  placesParserTask = new ParserTask(PLACES);
  
                  // Start parsing google places json data
                  // This causes to execute doInBackground() of ParserTask class
                  placesParserTask.execute(result);
  
                  break;
  
              case PLACES_DETAILS :
                  // Creating ParserTask for parsing Google Places
                  placeDetailsParserTask = new ParserTask(PLACES_DETAILS);
  
                  // Starting Parsing the JSON string
                  // This causes to execute doInBackground() of ParserTask class
                  placeDetailsParserTask.execute(result);
          }
      }
  }
  
  /** A class to parse the Google Places in JSON format */
  private class ParserTask extends AsyncTask&lt;String, Integer, List&lt;HashMap&lt;String,String&gt;&gt;&gt; implements OnMapReadyCallback {
  
      int parserType = 0;
  
      public ParserTask(int type){
          this.parserType = type;
      }
  
      @Override
      protected List&lt;HashMap&lt;String, String&gt;&gt; doInBackground(String... jsonData) {
  
          JSONObject jObject;
          List&lt;HashMap&lt;String, String&gt;&gt; list = null;
  
          try{
              jObject = new JSONObject(jsonData[0]);
  
              switch(parserType){
                  case PLACES :
                      PlaceJSONParser placeJsonParser = new PlaceJSONParser();
                      // Getting the parsed data as a List construct
                      list = placeJsonParser.parse(jObject);
                      break;
                  case PLACES_DETAILS :
                      PlaceDetailsJSONParser placeDetailsJsonParser = new PlaceDetailsJSONParser();
                      // Getting the parsed data as a List construct
                      list = placeDetailsJsonParser.parse(jObject);
              }
  
          }catch(Exception e){
              Log.d("Exception",e.toString());
          }
          return list;
      }
  
      @Override
      protected void onPostExecute(List&lt;HashMap&lt;String, String&gt;&gt; result) {
  
          switch(parserType){
              case PLACES :
                  String[] from = new String[] { "description"};
                  int[] to = new int[] { android.R.id.text1 };
  
                  // Creating a SimpleAdapter for the AutoCompleteTextView
                  SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), result, android.R.layout.simple_list_item_1, from, to);
  
                  // Setting the adapter
                  atvPlaces.setAdapter(adapter);
                  break;
              case PLACES_DETAILS :
                  HashMap&lt;String, String&gt; hm = result.get(0);
  
                  // Getting latitude from the parsed data
                  double latitude = Double.parseDouble(hm.get("lat"));
  
                  // Getting longitude from the parsed data
                  double longitude = Double.parseDouble(hm.get("lng"));
  
                  // Getting reference to the SupportMapFragment of the activity_main.xml
                  SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
  
                  // Getting GoogleMap from SupportMapFragment
                  fm.getMapAsync(this);
  
                  LatLng point = new LatLng(latitude, longitude);
  
                  CameraUpdate cameraPosition = CameraUpdateFactory.newLatLng(point);
                  CameraUpdate cameraZoom = CameraUpdateFactory.zoomBy(5);
  
                  // Showing the user input location in the Google Map
                 mMap.moveCamera(cameraPosition);
               mMap.animateCamera(cameraZoom);
  
                  MarkerOptions options = new MarkerOptions();
                  options.position(point);
                  options.title("Position");
                  options.snippet("Latitude:"+latitude+",Longitude:"+longitude);
  
                  // Adding the marker in the Google Map
                mMap.addMarker(options);
  
                  break;
          }
      }
  
      @Override
      public void onMapReady(GoogleMap googleMap) {
          mMap=googleMap;
      }
  }
  </code></pre>
  
  <p>LogCat </p>
  
  <pre><code> FATAL EXCEPTION: main
                Process: com.example.awais.mapapp1, PID: 13727
                java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.moveCamera(com.google.android.gms.maps.CameraUpdate)' on a null object reference 
                at com.example.awais.mapapp1.MainActivity$ParserTask.onPostExecute(MainActivity.java:332)
                at com.example.awais.mapapp1.MainActivity$ParserTask.onPostExecute(MainActivity.java:262)
                 at android.os.AsyncTask.finish(AsyncTask.java:664)
                 at android.os.AsyncTask.-wrap1(AsyncTask.java)
                 at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:681)
                 at android.os.Handler.dispatchMessage(Handler.java:102)
                 at android.os.Looper.loop(Looper.java:148)
                 at android.app.ActivityThread.main(ActivityThread.java:5452)
                 at java.lang.reflect.Method.invoke(Native Method)
                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:762)
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
  04-12 13:40:03.173 13727-13733/com.example.awais.mapapp1 W/art: Suspending all threads took: 7.995ms
  </code></pre>