title: error: Attempt to invoke interface method 'int java.util.List.size()'
body: <p>i try to build an app that show a route and draw it, for after calculate distance an travel time, for all points A + B + C + D...  but it show this error, i don't know how fix.</p>
  
  <p>i looking for similar answers, but no response for this case</p>
  
  <pre><code>TAL EXCEPTION: main
                    Process: com.elgeos.wayp.wa, PID: 17963
                    java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
                        at com.elgeos.wayp.wa.PathGoogleMapActivity$ParserTask.onPostExecute(PathGoogleMapActivity.java:139)
                        at com.elgeos.wayp.wa.PathGoogleMapActivity$ParserTask.onPostExecute(PathGoogleMapActivity.java:113)
                        at android.os.AsyncTask.finish(AsyncTask.java:651)
                        at android.os.AsyncTask.-wrap1(AsyncTask.java)
                        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
                        at android.os.Handler.dispatchMessage(Handler.java:102)
                        at android.os.Looper.loop(Looper.java:148)
                        at android.app.ActivityThread.main(ActivityThread.java:5417)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p>Below i attach my full java activity, Android Studio show me all ok, but when i debug app, fail app</p>
  
  <pre><code>package com.elgeos.wayp.wa;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  
  import org.json.JSONObject;
  
  import android.graphics.Color;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  import android.util.Log;
  
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.OnMapReadyCallback;
  import com.google.android.gms.maps.SupportMapFragment;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  import com.google.android.gms.maps.model.PolylineOptions;
  
  public class PathGoogleMapActivity extends FragmentActivity  implements OnMapReadyCallback {
  
      private static final LatLng LOWER_MANHATTAN = new LatLng(40.722543,
              -73.998585);
      private static final LatLng BROOKLYN_BRIDGE = new LatLng(40.7057, -73.9964);
      private static final LatLng WALL_STREET = new LatLng(40.7064, -74.0094);
  
      GoogleMap mMap;
      final String TAG = "PathGoogleMapActivity";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_path_google_map);
          SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                  .findFragmentById(R.id.map);
          mapFragment.getMapAsync(this);
  
  
  
  
      }
  
      @Override
      public void onMapReady(GoogleMap googleMap) {
          mMap = googleMap;
  
          MarkerOptions options = new MarkerOptions();
          options.position(LOWER_MANHATTAN);
          options.position(BROOKLYN_BRIDGE);
          options.position(WALL_STREET);
          mMap.addMarker(options);
          String url = getMapsApiDirectionsUrl();
          ReadTask downloadTask = new ReadTask();
          downloadTask.execute(url);
  
          mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(BROOKLYN_BRIDGE,
                  13));
  
          addMarkers();
      }
  
      private String getMapsApiDirectionsUrl() {
          String waypoints = "waypoints=optimize:true|"
                  + LOWER_MANHATTAN.latitude + "," + LOWER_MANHATTAN.longitude
                  + "|" + "|" + BROOKLYN_BRIDGE.latitude + ","
                  + BROOKLYN_BRIDGE.longitude + "|" + WALL_STREET.latitude + ","
                  + WALL_STREET.longitude;
  
          String sensor = "sensor=false";
          String params = waypoints + "&amp;" + sensor;
          String output = "json";
          String url = "https://maps.googleapis.com/maps/api/directions/"
                  + output + "?" + params;
          return url;
      }
  
      private void addMarkers() {
          if (mMap != null) {
              mMap.addMarker(new MarkerOptions().position(BROOKLYN_BRIDGE)
                      .title("First Point"));
              mMap.addMarker(new MarkerOptions().position(LOWER_MANHATTAN)
                      .title("Second Point"));
              mMap.addMarker(new MarkerOptions().position(WALL_STREET)
                      .title("Third Point"));
          }
      }
  
  
  
      private class ReadTask extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected String doInBackground(String... url) {
              String data = "";
              try {
                  HttpConnection http = new HttpConnection();
                  data = http.readUrl(url[0]);
              } catch (Exception e) {
                  Log.d("Background Task", e.toString());
              }
              return data;
          }
  
          @Override
          protected void onPostExecute(String result) {
              super.onPostExecute(result);
              new ParserTask().execute(result);
          }
      }
  
      private class ParserTask extends
              AsyncTask&lt;String, Integer, List&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt;&gt; {
  
          @Override
          protected List&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt; doInBackground(
                  String... jsonData) {
  
              JSONObject jObject;
              List&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt; routes = null;
  
              try {
                  jObject = new JSONObject(jsonData[0]);
                  PathJSONParser parser = new PathJSONParser();
                  routes = parser.parse(jObject);
              } catch (Exception e) {
                  e.printStackTrace();
              }
              return routes;
          }
  
          @Override
          protected void onPostExecute(List&lt;List&lt;HashMap&lt;String, String&gt;&gt;&gt; routes) {
              ArrayList&lt;LatLng&gt; points = null;
              PolylineOptions polyLineOptions = null;
  
              // traversing through routes
              for (int i = 0; i &lt; routes.size(); i++) {
                  points = new ArrayList&lt;LatLng&gt;();
                  polyLineOptions = new PolylineOptions();
                  List&lt;HashMap&lt;String, String&gt;&gt; path = routes.get(i);
  
                  for (int j = 0; j &lt; path.size(); j++) {
                      HashMap&lt;String, String&gt; point = path.get(j);
  
                      double lat = Double.parseDouble(point.get("lat"));
                      double lng = Double.parseDouble(point.get("lng"));
                      LatLng position = new LatLng(lat, lng);
  
                      points.add(position);
                  }
  
                  polyLineOptions.addAll(points);
                  polyLineOptions.width(2);
                  polyLineOptions.color(Color.BLUE);
              }
  
              mMap.addPolyline(polyLineOptions);
          }
      }
  }
  </code></pre>