mrmans0n / smart-location-lib

Android library project that lets you manage the location updates to be as painless as possible
1.65k stars 353 forks source link

Null Pointer Exception around LocationGooglePlayServicesWithFallbackProvider.java #181

Closed badsaarow closed 3 years ago

badsaarow commented 7 years ago

My app was crashed as below exception log.

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference com.google.android.gms.common.zze.isGooglePlayServicesAvailable () com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable () io.nlopez.smartlocation.location.providers.LocationGooglePlayServicesWithFallbackProvider.<init> (LocationGooglePlayServicesWithFallbackProvider.java:31) io.nlopez.smartlocation.SmartLocation.location (SmartLocation.java:59) kr.co.digitalpie.pubparkandroid.fragment.AttendanceFragment.stopLocation (AttendanceFragment.java:366) kr.co.digitalpie.pubparkandroid.fragment.AttendanceFragment.access$500 (AttendanceFragment.java:56) kr.co.digitalpie.pubparkandroid.fragment.AttendanceFragment$2.run (AttendanceFragment.java:240) android.os.Handler.handleCallback (Handler.java:739) android.os.Handler.dispatchMessage (Handler.java:95) android.os.Looper.loop (Looper.java:145) android.app.ActivityThread.main (ActivityThread.java:6917) java.lang.reflect.Method.invoke (Method.java) java.lang.reflect.Method.invoke (Method.java:372) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1404) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1199)

Here is my code private void stopLocation() { SmartLocation.with(getActivity()).location().stop(); }

My build.gradle was like below. android { compileSdkVersion 24 buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 17 targetSdkVersion 23 } ... apply plugin: 'com.google.gms.google-services' dependencies { compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.android.support:design:24.2.1' compile 'com.android.support:support-v4:24.2.1' compile 'com.google.android.gms:play-services:9.8.0' compile 'com.google.android.gms:play-services-maps:9.8.0' compile 'com.google.android.gms:play-services-location:9.8.0' compile ('io.nlopez.smartlocation:library:3.2.9') { transitive = true } ... }

sictiru commented 7 years ago

I have the same issue but I'm calling stop() after SmartLocation.with(getActivity()).location().oneFix().start(). Do we need to stop() after oneFix() ?

mrmans0n commented 7 years ago

Yes

On Tue, Jul 25, 2017, 00:40 Andrei notifications@github.com wrote:

I have the same issue but I'm calling stop() after SmartLocation.with(getActivity()).location().oneFix().start(). Do we need to stop() after oneFix() ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mrmans0n/smart-location-lib/issues/181#issuecomment-317586149, or mute the thread https://github.com/notifications/unsubscribe-auth/AAgnI2qr4_Uh7Cuz_H6Dib7yfpm_AIwQks5sRSt1gaJpZM4K-kcF .

badsaarow commented 3 years ago

Close. It’s too long opened