Check whether lastLocation is null before calling getTime()
MODIFY
src/android/plugin/google/maps/PluginLocationService.java
src/android/plugin/google/maps/PluginLocationService.java
@@ -450,7 +450,7 @@ public class PluginLocationService extends CordovaPlugin {
@Override
public void onSuccess(Location location) {
lastLocation = location;
- if (Calendar.getInstance().getTimeInMillis() - lastLocation.getTime() <= 2000) {
+ if (lastLocation != null && Calendar.getInstance().getTimeInMillis() - lastLocation.getTime() <= 2000) {
Log.d(TAG, "---->The last location is obtained in 2 sec.");
//---------------------------------------------------------------------
// If the user requests the location in two seconds from the last time,

Check whether lastLocation is null before calling getTime()