Search code examples
androidgeolocationstackmob

Error in sample code SnapStack Plus Android


I am running a downloaded application called Snaptack Plus from StackMob. The app runs but when I select a button I am getting an error, the stack trace with the error is below. This is where I think the problem is coming from:

01-11 17:46:52.751: E/AndroidRuntime(18584): FATAL EXCEPTION: main
01-11 17:46:52.751: E/AndroidRuntime(18584): java.lang.NullPointerException
01-11 17:46:52.751: E/AndroidRuntime(18584): at com.stackmob.apps.snapstack.extend.BaseActivity.getStackMobGeoPoint(BaseActivity.java:136)

When I step through the code it falls through at this code snippet

protected StackMobGeoPoint getStackMobGeoPoint() {
    Location loc = getGPSTracker().getLocation();
    if (loc != null) {
        return new StackMobGeoPoint(loc.getLongitude(), loc.getLatitude());
    } else {
        return null;
    }
}

I think the loc object is the problem (because this is where it falls through), so can someone give me some pointers?


Solution

  • Are you running this from an emulator? it seems that getGPSTracker() is returning null