mauron85 / react-native-background-geolocation

Background and foreground geolocation plugin for React Native. Tracks user when app is running in background.
Apache License 2.0
1.33k stars 561 forks source link

Unable to create service com.marianhello.bgloc.service.LocationServiceImpl: java.lang.SecurityException: uid 10293 cannot explicitly add accounts of type: xx.xx.xx.mauron85.bgloc.account #529

Open abraham-rose opened 3 years ago

abraham-rose commented 3 years ago

Your Environment

Context

The issue was found in the Firebase crashlytics for the application in production. It was found only in one user who uses realme device. Brand: Realme Model: realme X Operating System Version: 10

Expected Behavior

No crashes to happen for the realme X user

Actual Behavior

Attaching the stack traces from crashlytics.

Fatal Exception: java.lang.RuntimeException: Unable to create service com.marianhello.bgloc.service.LocationServiceImpl: java.lang.SecurityException: uid 10293 cannot explicitly add accounts of type: xx.xx.xx.mauron85.bgloc.account at android.app.ActivityThread.handleCreateService(ActivityThread.java:4226) at android.app.ActivityThread.access$200(ActivityThread.java:240) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2081) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:228) at android.app.ActivityThread.main(ActivityThread.java:7782) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)

Caused by java.lang.SecurityException: uid 10293 cannot explicitly add accounts of type: xx.xx.xx.mauron85.bgloc.account at android.os.Parcel.createException(Parcel.java:2087) at android.os.Parcel.readException(Parcel.java:2055) at android.os.Parcel.readException(Parcel.java:2003) at android.accounts.IAccountManager$Stub$Proxy.addAccountExplicitly(IAccountManager.java:1660) at android.accounts.AccountManager.addAccountExplicitly(AccountManager.java:889) at com.marianhello.bgloc.sync.AccountHelper.CreateSyncAccount(AccountHelper.java:24) at com.marianhello.bgloc.service.LocationServiceImpl.onCreate(LocationServiceImpl.java:192) at android.app.ActivityThread.handleCreateService(ActivityThread.java:4214) at android.app.ActivityThread.access$200(ActivityThread.java:240) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2081) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:228) at android.app.ActivityThread.main(ActivityThread.java:7782) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)

Caused by android.os.RemoteException: Remote stack trace: at com.android.server.accounts.AccountManagerService.addAccountExplicitlyWithVisibility(AccountManagerService.java:480) at com.android.server.accounts.AccountManagerService.addAccountExplicitly(AccountManagerService.java:1646) at android.accounts.IAccountManager$Stub.onTransact(IAccountManager.java:630) at com.android.server.accounts.AccountManagerService.onTransact(AccountManagerService.java:1082) at android.os.Binder.execTransactInternal(Binder.java:1021)

Possible Fix

Steps to Reproduce

Unable to reproduce from our end.

Context

This bug has affected the realme x user 77 times over a duration of 7 days. The crashes seems to be happening 8% background as per the crashlytics data.

Debug logs

dcoellarb commented 3 years ago

Same problem here, any solution?

chungweileong94 commented 3 years ago

I faced the same issue, apparently, this basically means that the device already has an account with the same account type. The good news is you can actually overwrite the default account type in build.gradle.

defaultConfig {
        ...
        resValue "string", "mauron85_bgloc_account_type", "${applicationId}.${applicationIdSuffix}.mauron85.bgloc.account"
}