Application crashes while loading the map showing current location and drawing line
<p>I am trying to implement the map showing the current location with the path. while running it crashes.</p>

<p>I checked the manifest too.. but I dont know what the error is..</p>

<p>PLease help me, I am new bee in android..</p>

<p>here is my code:</p>

<p>MapActivity.java</p>

<pre><code>package com.GoogleMaps;

import java.util.List;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;

public class MapsActivity extends MapActivity {
/** Called when the activity is first created. */

 private MapView mapView;
 private LocationManager lm;
 private LocationListener ll;
 private MapController mc;
 GeoPoint p = null;
 Drawable defaultMarker = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mapView = (MapView)findViewById(R.id.mapview);
    //show zoom in/out buttons
    mapView.setBuiltInZoomControls(true);
    //Standard view of the map(map/sat)
    mapView.setSatellite(false);
    //get controller of the map for zooming in/out
    mc = mapView.getController();
    // Zoom Level
    mc.setZoom(18); 

    // MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
    List&lt;Overlay&gt; list = mapView.getOverlays();
   //  list.add(myLocationOverlay);

    lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

    ll = new MyLocationListener();

    lm.requestLocationUpdates(
            LocationManager.GPS_PROVIDER,
            0,
            0,
            ll);

    //Get the current location in start-up
    GeoPoint initGeoPoint = new GeoPoint(
           (int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()*1000000),
           (int)(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude()*1000000));
           mc.animateTo(initGeoPoint);
}

protected class MyLocationOverlay extends com.google.android.maps.Overlay {

        @Override
        public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
            Paint paint = new Paint();

            super.draw(canvas, mapView, shadow);
            // Converts lat/lng-Point to OUR coordinates on the screen.
            Point myScreenCoords = new Point();

            mapView.getProjection().toPixels(p, myScreenCoords);

            paint.setStrokeWidth(1);
            paint.setARGB(255, 255, 255, 255);
            paint.setStyle(Paint.Style.STROKE);

            Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);

            canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint);
            canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint);
            return true;
        }
    }

private class MyLocationListener implements LocationListener{

      public void onLocationChanged(Location argLocation) {
       // TODO Auto-generated method stub
       GeoPoint myGeoPoint = new GeoPoint((int)(argLocation.getLatitude()*1000000), (int)(argLocation.getLongitude()*1000000));

       Toast.makeText(getBaseContext(),
               "New location latitude [" +argLocation.getLatitude() +
               "] longitude [" + argLocation.getLongitude()+"]",
               Toast.LENGTH_SHORT).show();


       mc.animateTo(myGeoPoint);

      }

      public void onProviderDisabled(String provider) {
       // TODO Auto-generated method stub
      }

      public void onProviderEnabled(String provider) {
       // TODO Auto-generated method stub
      }

      public void onStatusChanged(String provider,
        int status, Bundle extras) {
       // TODO Auto-generated method stub
      }
     }    
protected boolean isRouteDisplayed() {
    return false;
}
}
</code></pre>

<p>main.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   &gt; 
 &lt;LinearLayout
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   &gt;
    &lt;TextView
     android:id="@+id/longitude"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:text="Longitude:"
  /&gt;
  &lt;TextView
   android:id="@+id/latitude"
   android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:text="Latitude:"
  /&gt;
 &lt;/LinearLayout&gt;
 &lt;com.google.android.maps.MapView
  android:id="@+id/mapview"
  android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="false"
  android:apiKey="0dB02TjP-H_UqgsDpfxAhtsvGo5Z8cUJsTeHeDA"
 /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>Manifest file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.GoogleMaps"
    android:versionCode="1"
    android:versionName="1.0" &gt;

    &lt;uses-sdk android:minSdkVersion="8" /&gt;

    &lt;application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" &gt;
        &lt;uses-library  android:required="true" android:name="com.google.android.maps"/&gt;
        &lt;activity
            android:label="@string/app_name"
            android:name=".MapsActivity" &gt;
           &lt;intent-filter&gt;
               &lt;action android:name="android.intent.action.MAIN" /&gt;
               &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
           &lt;/intent-filter&gt;
       &lt;/activity&gt;
  &lt;uses-library android:name="com.google.android.maps" /&gt;
   &lt;/application&gt;
   &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
   &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
   &lt;uses-sdk android:minSdkVersion="8" /&gt;
&lt;/manifest&gt;
</code></pre>

<p>logcat file:</p>

<pre><code>11-29 03:26:49.620: D/AndroidRuntime(671): Shutting down VM
11-29 03:26:49.620: W/dalvikvm(671): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-29 03:26:49.640: E/AndroidRuntime(671): FATAL EXCEPTION: main
11-29 03:26:49.640: E/AndroidRuntime(671): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.GoogleMaps/com.GoogleMaps.MapsActivity}: java.lang.NullPointerException
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.os.Looper.loop(Looper.java:123)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-29 03:26:49.640: E/AndroidRuntime(671):  at java.lang.reflect.Method.invokeNative(Native Method)
11-29 03:26:49.640: E/AndroidRuntime(671):  at java.lang.reflect.Method.invoke(Method.java:521)
11-29 03:26:49.640: E/AndroidRuntime(671):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-29 03:26:49.640: E/AndroidRuntime(671):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-29 03:26:49.640: E/AndroidRuntime(671):  at dalvik.system.NativeStart.main(Native Method)
11-29 03:26:49.640: E/AndroidRuntime(671): Caused by: java.lang.NullPointerException
11-29 03:26:49.640: E/AndroidRuntime(671):  at com.GoogleMaps.MapsActivity.onCreate(MapsActivity.java:65)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-29 03:26:49.640: E/AndroidRuntime(671):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-29 03:26:49.640: E/AndroidRuntime(671):  ... 11 more
11-29 03:26:52.320: I/Process(671): Sending signal. PID: 671 SIG: 9
</code></pre>
