# Geofences on Android with GoogleApiClient

**URL:** <https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 4, 2016, 10:44am UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449 "2016-03-04T10:44:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![macsimus](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/macsimus/32/109104_2.png) [@macsimus](https://forums.kodeco.com/u/macsimus)\
**Post date:** [March 4, 2016, 10:44am UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/1 "2016-03-04T10:44:09Z")

</div>

In this tutorial you'll learn how to leverage GoogleApiClient to add geofences to an Android app, as well as post notifications when a geofence is crossed.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/1773-geofences-on-android-with-googleapiclient](https://www.raywenderlich.com/1773-geofences-on-android-with-googleapiclient)

---

<div class="post-metadata">

**Author:** ![sharathnasa](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/sharathnasa/32/8465_2.png) [@sharathnasa](https://forums.kodeco.com/u/sharathnasa)\
**Post date:** [March 14, 2016, 3:59pm UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/2 "2016-03-14T15:59:52Z")

</div>

Hello Ray,

Thanks a lot for such an awesome tutorial. I’m facing a problem where the app is getting force closed by saying goggleapliclient is not connected. Please find the details of the error as below.

java.lang.IllegalStateException: GoogleApiClient is not connected yet.  
at com.google.android.gms.internal.zzme.zzb(Unknown Source)  
at com.google.android.gms.internal.zzmi.zzb(Unknown Source)  
at com.google.android.gms.internal.zzmg.zzb(Unknown Source)  
at com.google.android.gms.location.internal.zzf.addGeofences(Unknown Source)  
at com.purvotara.shanchaconsumer.network.geofence.GeofenceController$1.onConnected(GeofenceController.java:52)  
at com.google.android.gms.common.internal.zzk.zzk(Unknown Source)  
at com.google.android.gms.internal.zzmg.zzi(Unknown Source)  
at com.google.android.gms.internal.zzme.zzpi(Unknown Source)  
at com.google.android.gms.internal.zzme.onConnected(Unknown Source)  
at com.google.android.gms.internal.zzmi.onConnected(Unknown Source)  
at com.google.android.gms.internal.zzlz.onConnected(Unknown Source)  
at com.google.android.gms.common.internal.zzj$zzg.zzqv(Unknown Source)  
at com.google.android.gms.common.internal.zzj$zza.zzc(Unknown Source)  
at com.google.android.gms.common.internal.zzj$zza.zzv(Unknown Source)  
at com.google.android.gms.common.internal.zzj$zzc.zzqx(Unknown Source)  
at com.google.android.gms.common.internal.zzj$zzb.handleMessage(Unknown Source)  
at android.os.Handler.dispatchMessage(Handler.java:102)  
at android.os.Looper.loop(Looper.java:135)  
at android.app.ActivityThread.main(ActivityThread.java:5236)  
at java.lang.reflect.Method.invoke(Native Method)  
at java.lang.reflect.Method.invoke(Method.java:372)  
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)  
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

Please let me know where it is going wrong…

---

<div class="post-metadata">

**Author:** ![mako5713](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mako5713/32/37310_2.png) [@mako5713](https://forums.kodeco.com/u/mako5713)\
**Post date:** [July 20, 2016, 11:00am UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/3 "2016-07-20T11:00:48Z")

</div>

Hello Ray,

I want to store and load the geofences in a sql database, but I don’t know how… ☹

Maybe you have a short advice for me, how I can solve this problem?

Thanks,  
Mario

---

<div class="post-metadata">

**Author:** ![miannoumanshah](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/miannoumanshah/32/54257_2.png) [@miannoumanshah](https://forums.kodeco.com/u/miannoumanshah)\
**Post date:** [January 12, 2017, 9:55am UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/4 "2017-01-12T09:55:54Z")

</div>

i am facing the same problem as mention by sharathnasa  
java.lang.IllegalStateException: GoogleApiClient is not connected yet.  
i come to know that two different instances of googleApiClient is created that what the issue is so there are possibly two solution either call GoogleApiClient in onCreate() method or make googleApiClient public static but none of them work for me can u provide me with a better solution thank you

---

<div class="post-metadata">

**Author:** ![aseokana](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aseokana/32/56241_2.png) [@aseokana](https://forums.kodeco.com/u/aseokana)\
**Post date:** [February 1, 2017, 9:55pm UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/5 "2017-02-01T21:55:38Z")

</div>

Hello Ray, and Everyone!

Is there a way I can hard code the geofences in the app so that there are some available geofences for the users when they install the app? So that they don’t have to add the geofences for themselves(adding the geofences will be optional for them). Please help. I’ve trying to do it for the past two months following this tutorial but I can’t seem to get it right.

Thank You!

---

<div class="post-metadata">

**Author:** ![anup\_dubey](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/anup_dubey/32/60373_2.png) [@anup\_dubey](https://forums.kodeco.com/u/anup_dubey)\
**Post date:** [March 16, 2017, 7:16pm UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/6 "2017-03-16T19:16:27Z")

</div>

i am not able to see the notification and not able to know wheather the geofence is working or not…what should i do

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [July 3, 2017, 6:10pm UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/7 "2017-07-03T18:10:03Z")

</div>

This tutorial is more than six months old, so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [July 3, 2017, 6:10pm UTC](https://forums.kodeco.com/t/geofences-on-android-with-googleapiclient/6449/8 "2017-07-03T18:10:06Z")

</div>

Closed on July 3, 2017, 6:10pm UTC


