googlesamples / google-services

A collection of quickstart samples demonstrating the Google APIs for Android and iOS
https://developers.google.com
Apache License 2.0
3.07k stars 2.53k forks source link

SecurityException rethrown from transaction Parcel, our app crashes #332

Open alexcohn opened 7 years ago

alexcohn commented 7 years ago

Step 3: Describe the problem:

With Crashlytics, we see the following crash for ~0.1% of Android 7.0 sessions. The crash happens very early after app launch, which makes sense because we initialize communication with Google Play Services as soon as the app is ready.

Fatal Exception: java.lang.SecurityException: Unknown calling package name 'package.name.redacted'.
       at android.os.Parcel.readException(Parcel.java:1693)
       at android.os.Parcel.readException(Parcel.java:1646)
       at com.google.android.gms.common.internal.zzv$zza$zza.zza(Unknown Source)
       at com.google.android.gms.common.internal.zzf.zza(Unknown Source)
       at com.google.android.gms.internal.zzaax$zzb$1.run(Unknown Source)
       at android.os.Handler.handleCallback(Handler.java:751)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:154)
       at android.os.HandlerThread.run(HandlerThread.java:61)

Steps to reproduce:

We were not able to reproduce the crash in lab. I found similar reports elsewhere:

Observed Results:

Jack@101 claims that this crash did never happen before they upgraded to Play Services 10.0.1. I can neither confirm nor deny this observation.

Expected Results:

I don't expect my app to crash even if Google Services have some internal problem.

Relevant Code:

I don't know which service caused this transaction to fail with SecurityException. The call stack we see in Crashlytics is only the exception extracted from the Parcel and rethrown.

One candidate is

GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context.getApplicationContext())

another

mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build();
mGoogleApiClient.connect();
ianbarber commented 7 years ago

We think this is maybe an issue in Google Analytics for Firebase failing to validate your package.

  1. Are you doing anything unusual around your package name? e.g. is this running in a wear app in some cases when the configuration is for the main app?
  2. Are you using the google-services plugin?
alexcohn commented 7 years ago

It could be related to Wear; the logs neither confirm nor deny this possibility. With your guidance, I can add some tracking to better understand the origin of this crash.

Yes, we have apply plugin: 'com.google.gms.google-services' in our gradle script.