Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecurityException: "fused" location provider requires ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission. #277

Open
tonyseben opened this issue Jan 2, 2020 · 3 comments

Comments

@tonyseben
Copy link

Found this SecurityException in my Crashlytics reports after integrating your sdk. Let me know How I can handle this issue.

Fatal Exception: java.lang.SecurityException: "fused" location provider requires ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission.
       at android.os.Parcel.createException(Parcel.java:1950)
       at android.os.Parcel.readException(Parcel.java:1918)
       at android.os.Parcel.readException(Parcel.java:1868)
       at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:755)
       at android.location.LocationManager.requestLocationUpdates(LocationManager.java:1007)
       at android.location.LocationManager.requestLocationUpdates(LocationManager.java:626)
       at io.nlopez.smartlocation.location.providers.LocationManagerProvider.start(LocationManagerProvider.java:65)
       at io.nlopez.smartlocation.location.providers.LocationGooglePlayServicesWithFallbackProvider.fallbackToLocationManager(LocationGooglePlayServicesWithFallbackProvider.java:88)
       at io.nlopez.smartlocation.location.providers.LocationGooglePlayServicesWithFallbackProvider.onConnectionSuspended(LocationGooglePlayServicesWithFallbackProvider.java:75)
       at io.nlopez.smartlocation.location.providers.LocationGooglePlayServicesProvider.onConnectionSuspended(LocationGooglePlayServicesProvider.java:235)
       at com.google.android.gms.common.internal.GmsClientEventManager.onUnintentionalDisconnection(com.google.android.gms:play-services-base@@17.1.0:47)
       at com.google.android.gms.common.api.internal.zaaw.zab(com.google.android.gms:play-services-base@@17.1.0:321)
       at com.google.android.gms.common.api.internal.zaaf.onConnectionSuspended(com.google.android.gms:play-services-base@@17.1.0:42)
       at com.google.android.gms.common.api.internal.zabe.onConnectionSuspended(com.google.android.gms:play-services-base@@17.1.0:106)
       at com.google.android.gms.common.api.internal.zap.onConnectionSuspended(com.google.android.gms:play-services-base@@17.1.0:9)
       at com.google.android.gms.common.internal.zaf.onConnectionSuspended(com.google.android.gms:play-services-base@@17.1.0:4)
       at com.google.android.gms.common.internal.BaseGmsClient$zzb.handleMessage(:40)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at com.google.android.gms.internal.common.zze.dispatchMessage(:8)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6718)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
@Marlinski
Copy link

I had the same issue when the location permission got removed while smartlocation was running.

@avianey
Copy link

avianey commented Feb 13, 2020

Obviously this check should wrap the if(singleUpdate) one

if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)

@avianey
Copy link

avianey commented Feb 13, 2020

In the meantime, one can silently catch the exception by registering a custom exception handler after crashlytics init Application#onCreate()

/**
 * To be registered after Crashlytics init
 * Catch for https://github.com/mrmans0n/smart-location-lib/issues/277
 */
private void handleSmartLocationExceptionSilently() {
    final Thread.UncaughtExceptionHandler defaultExceptionHandler = getDefaultUncaughtExceptionHandler();
    setDefaultUncaughtExceptionHandler((t, e) -> {
        if (e != null && e.getStackTrace() != null
                && e.getStackTrace().length > 6
                && e.getStackTrace()[6].toString().contains("io.nlopez.smartlocation")
                && e.getMessage() != null
                && e.getMessage().contains("location provider requires")) {
            return;
        }
        if (defaultExceptionHandler != null) {
            defaultExceptionHandler.uncaughtException(t, e);
        }
    });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants