title: com.google.android.gms.maps.CameraUpdate on a null object reference
body: <p>this is exactly the tittle "Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.animateCamera(com.google.android.gms.maps.CameraUpdate)' on a null object reference", after press search, suddenly to main activity</p>
  
  <p>logcat error</p>
  
  <pre><code>E/Response:: [{"lat":"-7.584844","lng":"110.825068","id":"11","nama":"SMK 3 NEGERI SURAKARTA"}]
  09-02 20:02:09.557 16955-16955/com.skripsi.axioo.percobaan5 E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.skripsi.axioo.percobaan5, PID: 16955
      java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.animateCamera(com.google.android.gms.maps.CameraUpdate)' on a null object reference
          at com.skripsi.axioo.percobaan5.MapsActivity$3.onResponse(MapsActivity.java:304)
          at com.skripsi.axioo.percobaan5.MapsActivity$3.onResponse(MapsActivity.java:276)
  </code></pre>
  
  <p>source code</p>
  
  <pre><code>    dialog.setMessage("Loading...");
      dialog.show();
  
      String url = "https://arizalway.000webhostapp.com/api/lokasi.php?nama="+ambilcari;
      url = url.replaceAll(" ", "%20");
      System.out.println(url);
  
  
  
  
      StringRequest strReq = new StringRequest(Request.Method.GET, url, new Response.Listener&lt;String&gt;() {
  
  
          @Override
          public void onResponse(String response) {
              Log.e("Response: ", response);
  
              try {
                  JSONArray jArray = new JSONArray(response);
  
                  for (int i = 0; i &lt; jArray.length(); i++) {
                      JSONObject jsonObject = jArray.getJSONObject(i);
  
  
                      System.out.println(Arrays.toString(latLng));
                      lati = Double.parseDouble(jsonObject.getString(LAT));
                      longi = Double.parseDouble(jsonObject.getString(LNG));
                      if (ambilcari.equals("")) {
  
  
                          center = new LatLng(-7.568737, 110.827062);
                          cameraPosition = new CameraPosition.Builder().target(center).zoom(15).build();
                          gMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
                          getLokasi();
  
                      } else {
                          center = new LatLng(lati, longi);
                          cameraPosition = new CameraPosition.Builder().target(center).zoom(20).build();
                          gMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  
  
                          getLokasi();
                      }
                  }
  </code></pre>
  
  <p>try it to search first solution but mostly the problem is not like this, this litte help for me, by adding supportfragment
  <a href="https://stackoverflow.com/questions/30116762/google-map-returning-nullpointerexception-google-maps-android-v2">Google Map returning nullpointerexception Google Maps Android V2</a>, anyone can tell me where the most critical error except from logcat, 
  this is full code <a href="https://pastebin.com/uYPbrAun" rel="nofollow noreferrer">https://pastebin.com/uYPbrAun</a></p>