问题
For a project, I am creating an android app that includes a WebView
, a service
that can switch from background to foreground and the LocationManager
relying on the NETWORK_PROVIDER
first and the GPS_PROVIDER
later.
In very random cases, upon starting the app, I find this exception in my logcat-output:
E/GoogleApiClientConnecting: GoogleApiClient connecting is in step STEP_SERVICE_BINDINGS_AND_SIGN_IN but received callback for step STEP_GETTING_REMOTE_SERVICE
java.lang.Exception
at qw.b(PG:25)
at qw.c(PG:36)
at Iw.c(PG:3)
at Gx.c(PG:2)
at ly.d(PG:15)
at gy.a(PG:19)
at iy.c(PG:6)
at hy.handleMessage(PG:46)
at android.os.Handler.dispatchMessage(Handler.java:106)
at oG.dispatchMessage(PG:1)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:65)
I checked my code and my dependencies and I don't seem to have anything related to a GoogleApiClient (which I found was outdated anyways). I don't (consciously) use Google Play Store integration or such things.
This exception seems to have the effect of slowing down my WebView very much (every single XHR or fetch is stalled for almost exactly 3seconds). How this could possibly be related, I don't know.
Plus, it only happens occasionally when starting or restarting the app (sometimes after clearing all data).
Any help would be appreciated, this is bugging me out.
回答1:
As right mentioned in the comments it's about Google service usage. By looking to the source of Google Gms library you can find a reason for that. During library initialization.
1) In details Google Service is initializing as Bound Service
in Android. And few int flags just used to annotate, whenever GoogleApiClient
is ready of not. By using two values STEP_SERVICE_BINDINGS_AND_SIGN_IN
and STEP_GETTING_REMOTE_SERVICE
. Some of that resources decompiled and you can check them here.
2) In order to resolve your issue you need to check initializing of that Service from other dependencies. Root library is com.google.android.gms
. You can check whenever this library in use by calling ./gradlew app:dependencies
.
3) At the same time of finding this library you could check what is out of date. Usage of GoogleApiClient
was deprecated and removed in 2017. So probably it's still used by old library which requires update.
回答2:
The only workaround I found was to completely disable "Google Play Protect" on the device (Settings -> Google -> Security -> Google Play Protect -> Cogwheel at the top -> General -> Scan apps with Play Protect).
It is very invasive and potentially dangerous. (It's enough for my evaluation, though.)
来源:https://stackoverflow.com/questions/58725618/where-does-a-googleclientapiconnected-exception-come-from