title: Error while setting the marker listener on Google map in android api 10
body: <p>I am trying to add the marker listener by implementing the <strong>OnMarkerClickListener</strong> and setting <strong>googleMap.setOnMarkerClickListener((OnMarkerClickListener)this)</strong> </p>
  
  <p>It is working fine with the actual device but giving the <strong>NullPointerException</strong> error on the emulator. It is also working fine with the device with api 19, but Why is this happening with emulator. </p>
  
  <p>I am using the SupportMapFragment for displaying the map.</p>
  
  <p>Here is the code</p>
  
  <pre><code>@SuppressLint("NewApi")
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.orderlayout);
  
      Log.i(TAG, "Started order onCreate method Activity");
  
      status = GooglePlayServicesUtil
              .isGooglePlayServicesAvailable(getApplicationContext());
      if (status == ConnectionResult.SUCCESS) {
          // Success! Do what you want
  
          mGoogleApiClient = new GoogleApiClient.Builder(this)
                  .addApi(LocationServices.API).addConnectionCallbacks(this)
                  .addOnConnectionFailedListener(this).build();
      } else {
          AlertDialog.Builder ad = new AlertDialog.Builder(this);
          ad.setTitle("Debugging");
          ad.setMessage("Error getting the GooglePlayServicesUtilities");
          ad.setNeutralButton("OK", new DialogInterface.OnClickListener() {
  
              @Override
              public void onClick(DialogInterface dialog, int which) {
                  //comeHome();
                  dialog.dismiss();
              }
  
          });
          AlertDialog dialog = ad.create();
          dialog.show();
      }
  
      // Setting the map features
      mMapFragment = (SupportMapFragment) getSupportFragmentManager()
              .findFragmentById(R.id.map);
      mMapFragment.getMapAsync(this);
      gMap = ((SupportMapFragment) getSupportFragmentManager()
              .findFragmentById(R.id.map)).getMap();
      gMap = mMapFragment.getMap();
  
      // set the click listeners for the marker in map
      try{
      gMap.setOnMarkerClickListener((OnMarkerClickListener) this);
      }catch(Exception e){Log.v(TAG,"Error setting the click listener for the marker: "+e.toString());}
  
  
      try {
          gMap.getUiSettings().setMyLocationButtonEnabled(true);
      } catch (Exception e) {
          Log.e("Buzz",
                  "Error with the current location button" + e.toString());
      }
      LatLng latLng = getCurrentLocation(this);
  
      Log.v(TAG,latLng.latitude+latLng.longitude+"");
      gMap.addMarker(new MarkerOptions().position( new LatLng(latLng.latitude,
                latLng.longitude)).title("Your Current Location"));
  
      try {
  
          gMap.setMyLocationEnabled(true);
  
      } catch (Exception e) {
          Log.e("Buzz",
                  "Error while enabling the current location" + e.toString());
      }
  </code></pre>
  
  <p>}       </p>
  
  <p>@Override
      public boolean onMarkerClick(final Marker marker)
      {
          return false;
      }</p>
  
  <p>and My Logcat is:</p>
  
  <pre><code>03-17 12:15:50.119: E/AndroidRuntime(562): FATAL EXCEPTION: main
  03-17 12:15:50.119: E/AndroidRuntime(562): java.lang.RuntimeException: Unable to start activity ComponentInfo{blr.infovita.buzzpharma/blr.infovita.buzzpharma.OrderActivity}: java.lang.NullPointerException
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.os.Handler.dispatchMessage(Handler.java:99)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.os.Looper.loop(Looper.java:123)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at java.lang.reflect.Method.invokeNative(Native Method)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at java.lang.reflect.Method.invoke(Method.java:507)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at dalvik.system.NativeStart.main(Native Method)
  03-17 12:15:50.119: E/AndroidRuntime(562): Caused by: java.lang.NullPointerException
  03-17 12:15:50.119: E/AndroidRuntime(562):  at blr.infovita.buzzpharma.OrderActivity.onCreate(OrderActivity.java:278)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  03-17 12:15:50.119: E/AndroidRuntime(562):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  03-17 12:15:50.119: E/AndroidRuntime(562):  ... 11 more
  </code></pre>