Because of this bug my team is deciding to not use geofencing at all. Is geofencing in Android something that is usable or not?
From the bug report:
On all in-house test devices everything runs fine with debug and release builds. However, for some users out there we get crash reports that indicate a problem with the API:
Fatal Exception: java.lang.SecurityException: Invalid API Key for package = de.stocard.stocard .Status code received = -1 at android.os.Parcel.readException(Parcel.java:1620) at android.os.Parcel.readException(Parcel.java:1573) at com.google.android.gms.common.internal.zzu$zza$zza.zza(Unknown Source) at com.google.android.gms.common.internal.zzd.zzqz(Unknown Source) at com.google.android.gms.internal.zzpw$zzc.zzapl(Unknown Source) at com.google.android.gms.internal.zzpw$zzf.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at com.google.android.gms.internal.zzrn.run(Unknown Source) at java.lang.Thread.run(Thread.java:818)
This happens on Android versions ranging from 4.4.2 to 7.0 with no noticeable pattern. The same applies to the device model and manufacturer: many and multiple manufacturers and models.
That sounds like a pretty severe Heisenbug.
Update:
There seems to be 2 different ways to do geofencing in Android:
- Using the Awareness[.fence] API
- Using the location Geofence API
We would need to use the Awareness API to get the features and battery-friendliness we desire.
NOTE:
I see 1 close vote due to "primarily opinion-based". So, let me be clear, I don't want unsupported opinion answers. I want facts, references, or specific expertise. I have done research and referenced a random crash bug with no reliable work around. I want others to note that they have successfully implemented geofencing and have either:
- Evidence that their apps have never encountered this bug (good crash reporting that has never caught
Invalid API Key for package
) - Have seen this bug and have successfully implemented a fix
- Never seen this bug
LocationManager.addProximityAlert()
way, no Google API being involved, there is no such problem... – Melancholic