title: java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
body: <p>I am very new to Java and Android Studio.</p>
  
  <p>I am using this sample code</p>
  
  <p><a href="http://javapapers.com/android/draw-path-on-google-maps-android-api/" rel="nofollow">http://javapapers.com/android/draw-path-on-google-maps-android-api/</a></p>
  
  <p>My project compiles and runs to the following point. I have tried debug mode and I can see the Google Map displays and the 3 markers are display. Then I get the following message.</p>
  
  <pre><code>9-03 00:06:04.459  19022-19022/nyc.mymaptest3 E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: nyc.mymaptest3, PID: 19022
      java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
              at nyc.mymaptest3.PathGoogleMapActivity$ParserTask.onPostExecute(PathGoogleMapActivity.java:128)
              at nyc.mymaptest3.PathGoogleMapActivity$ParserTask.onPostExecute(PathGoogleMapActivity.java:101)
              at android.os.AsyncTask.finish(AsyncTask.java:632)
              at android.os.AsyncTask.access$600(AsyncTask.java:177)
              at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:145)
              at android.app.ActivityThread.main(ActivityThread.java:5938)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
  </code></pre>
  
  <p>I feel like the routes being returned are empty / null and I do not know how to debug this any further.</p>
  
  <p>Line 101 starts here >>></p>
  
  <pre><code>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;
          }
  </code></pre>
  
  <p>Line 128 shown below >>></p>
  
  <pre><code>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);
  
  Line 128            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);
              }
  
              googleMap.addPolyline(polyLineOptions);
          }
  </code></pre>