Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is geofencing completely unusable in Android?

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:

  1. Using the Awareness[.fence] API
  2. 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:

  1. Evidence that their apps have never encountered this bug (good crash reporting that has never caught Invalid API Key for package)
  2. Have seen this bug and have successfully implemented a fix
  3. Never seen this bug
like image 742
Bruno Bronosky Avatar asked Feb 06 '17 21:02

Bruno Bronosky


1 Answers

The bug you linked already contained all the information, didn't it?

There is a bug in our checks that is sometimes throwing this SecurityException when there is a network error to authenticate. The fix will rollout in the next version of Google Play services.

For now, the best workaround would be set up an UncaughtExceptionHandler on the thread that you call GoogleApiClient.connect(). For most folks, this would be on the main thread, which you can get via Looper.myLooper().getThread().

Update

Well, to answer your question "Is geofencing completely unusable in Android?", I'd say no, it is not "completely" unusable but obviously contains a few issues.

Should you not use geofencing at all because of these bugs? I guess that heavily depends on the use case and is indeed an opinion based question. As always with mobile devices, you can never be 100% sure if something works. Your mobile might have no signal and even if there were no bugs in the code it might still not get notified about a certain location for various reasons. On mobile it's all about how you deal with errors.

I'd implement whatever you want to implement, try to do what was suggested in the bug ticket (the UncaughtExceptionHandler) to catch the error and implement analytics/crash reports in the app so that you at least will get information about how often this really happens out there in the field.

Make it clear to your users that there is no 100% guarantee that the geofence feature of your app works at all times due to the underlying system and I think they will still be happy to have the feature. Probably have some FAQ somewhere in your app or on your homepage which adresses the known issues. Hope this helps you make a decission

like image 72
xxtesaxx Avatar answered Nov 05 '22 04:11

xxtesaxx