yayaa / LocationManager

Simplify getting user's location for Android
806 stars 187 forks source link

NPE on googleApiClient #43

Closed swratten closed 7 years ago

swratten commented 7 years ago

Hi,

I am using this library in production and am unable to repro this on my devices but am getting this exception on many different users devices, I have error reporting through crashlytics and this is my highest crash.

Stack Trace:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.location.LocationAvailability.isLocationAvailable()' on a null object reference at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.getLocationAvailability(SourceFile:100) at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.checkLastKnowLocation(SourceFile:196) at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationProvider.onConnected(SourceFile:105) at com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.onConnected(SourceFile:110)

I am extending LocationBaseActivity and my Location Configuration is:

@Override
public LocationConfiguration getLocationConfiguration() {
return new LocationConfiguration.Builder().askForPermission(new PermissionConfiguration.Builder().build())
                .useGooglePlayServices(new GooglePlayServicesConfiguration.Builder()
                        .askForGooglePlayServices(true)
                        .setWaitPeriod(5 * 1000)
                        .build())
                .useDefaultProviders(new DefaultProviderConfiguration.Builder()
                        .acceptableTimePeriod(2 * 60 * 60 * 1000)
                        .setWaitPeriod(ProviderType.GPS, 10 * 1000)
                        .setWaitPeriod(ProviderType.NETWORK, 5 * 1000)
                        .gpsMessage("Would you mind to turn GPS on?").build())
                .build();
    }

After users on the app login to their account, I check location using: getLocation(); inherited from LocationBaseActivity

Could you please add a null check to com.yayandroid.locationmanager.providers.locationprovider.GooglePlayServicesLocationSource.getLocationAvailability(SourceFile:100) for variable googleApiClient