Recently I see an increase of error reported from Firebase Crashlytic on the following
Caused by java.lang.SecurityException: uid 10172 cannot explicitly add accounts of type: com.mypackage.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)
It got triggered from
accountManager.addAccountExplicitly(defaultAccount, null, null)
Based on the Firebase Crashlytic report, it happens only on Android 9 and 10 and across Samsung, Realme and OPPO devices
On my end, I try to replicate on Android P and Android 10 devices, and the code got triggered without issue.
I have search through StackOverflow, such as
Android app crashes on addAccountExplicitly(account, password, null);, Android SecurityException: uid xxxxx cannot explicitly add accounts, https://stackoverflow.com/a/58591203/3286489, https://stackoverflow.com/a/37348909/3286489, https://stackoverflow.com/a/16972048/3286489, and Android Adding Account with AccountManager.
They are for replicable issues, hence it's not of use for me.
I check also found like
https://github.com/signalapp/Signal-Android/issues/9311 (Android 10) https://github.com/signalapp/Signal-Android/issues/9296 (Android 9 - Pie?) https://github.com/signalapp/Signal-Android/issues/9349 (Another Android 10, on One Plus)
Either starting from Android P, there's more security update that we need to change our code or the Android P and 10 have some bug related to this issue? Anyone has encountered this issue lately?