title: Android Google Map V3 PolyLine cannot be drawn
body: <p>Getting this error while trying to match PolyLine on Google Map</p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to read from field 'float
    com.google.android.gms.maps.model.PolylineOptions.c' on a null object
    reference</p>
  </blockquote>
  
  <p>This is the line mentioned in Logcat</p>
  
  <blockquote>
    <p>at
    testappmapv2.PathGoogleMapActivity$ParserTask.onPostExecute(PathGoogleMapActivity.java:208)</p>
    
    <p>googleMap.addPolyline(polyLineOptions);</p>
  </blockquote>
  
  <p>This is my Activity Code:</p>
  
  <pre><code>import android.app.AlarmManager; import android.app.PendingIntent;
  import android.content.Context; import android.content.Intent;
  import android.graphics.Color; import android.location.Location;               
  
  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.SupportMapFragment;  
  import com.google.android.gms.maps.model.LatLng;  
  import com.google.android.gms.maps.model.Marker;  
  import com.google.android.gms.maps.model.MarkerOptions;  
  import com.google.android.gms.maps.model.PolylineOptions;  
  import com.parse.ParseException; 
  import com.parse.ParseGeoPoint;  
  import com.parse.ParseObject; 
  import com.parse.ParseQuery;
  
  import org.json.JSONObject;
  import java.util.ArrayList; import java.util.HashMap; 
  import java.util.List;
  
   public class PathGoogleMapActivity extends FragmentActivity {
  
           Location mCurrentLocation;
           String mLastUpdateTime;
           GoogleMap googleMap;
           LatLng visitedPoints, currentPoints;
           final String TAG = "PathGoogleMapActivity";
           MarkerOptions options;
           Marker marker;
           private final String DIRECTIONS_API_KEY = "*****************";
           private String parseClass = "LocationManager";
           private String User_id = "12345";
           private List&lt;ParseObject&gt; list;
           private List&lt;LatLng&gt; latLngList=new ArrayList&lt;LatLng&gt;();
  
           @Override
           protected void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.activity_path_google_map);
               SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
                       .findFragmentById(R.id.map);
               googleMap = fm.getMap();
               googleMap.getUiSettings().setZoomControlsEnabled(true);        
  
           }
  
  
  
           @Override
           protected void onResume() {
               super.onResume();
  
               try {
                   ParseQuery&lt;ParseObject&gt; parseQuery = ParseQuery.getQuery(parseClass);
                   parseQuery.whereEqualTo("User_Id", User_id);
  
                   list = parseQuery.find();
  
                   final ArrayList visitedPoint = (ArrayList) list.get(0).get("VisitedPoint");
  
                   for (Object parseGeoPoint : visitedPoint) {
  
                       ParseGeoPoint geoPoint = (ParseGeoPoint) parseGeoPoint;
                       LatLng latLng = new LatLng(geoPoint.getLatitude(), geoPoint.getLongitude());
                       latLngList.add(latLng);
                       Log.i(TAG, "parseGeoPoint" + latLng.toString());
                   }
  
                   googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLngList.get(latLngList.size()-1),
      15.0f));
  
                   Log.i(TAG, "Size of List: " + list.size());
                   Log.i(TAG, "ArrayList: " + visitedPoint.size());
                   Log.i(TAG, "ArrayList: " + visitedPoint.toString());
  
  
               } catch (ParseException e) {
                   e.printStackTrace();
               }
  
               for(int i=0;i&lt;latLngList.size()-1;i++)
               {
                   String url = getMapsApiDirectionsUrl(latLngList.get(i), latLngList.get(i+1));
                   ReadTask downloadTask = new ReadTask();
                   downloadTask.execute(url);
                   addMarkers(latLngList.get(i+1));
               }    }
  
  
  
           private String getMapsApiDirectionsUrl(LatLng start, LatLng end) {
  
               String output = "json";
               String url = "https://maps.googleapis.com/maps/api/directions/json?"
                       + "origin=" + start.latitude + "," + start.longitude
                       + "&amp;destination=" + end.latitude + "," + end.longitude
                       + "&amp;sensor=false&amp;units=metric&amp;mode=walking&amp;key=" + DIRECTIONS_API_KEY;
               return url;
           }
  
           private void addMarkers(LatLng latLng) {      
  
               marker = googleMap.addMarker(new MarkerOptions().position(latLng).title("You are here"));
           }
  
           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);
                   }
  
                   googleMap.addPolyline(polyLineOptions);
               }}}
  </code></pre>
  
  <p>I've ensured that GeoPoints are coming from Parse Server.
  Any Help will be appreciated.
  Thanks</p>