LocationClient setMockMode and setMockLocation are not defined?

1.4k views Asked by At

Been playing with android geofences but testing is becoming an issue. I need to mock the device location in order to trigger the enter/leave events but so far I am unable to find a way to do this.

In the documentation of the LocationClient there are two methods that seem to do what I need:

but I cannot compile any project with those methods as the compiler complains these symbols do not exists:

  SujGeoService2.java:296: error: cannot find symbol
    mLocClient.setMockMode(true);
              ^
  symbol:   method setMockMode(boolean)
  location: variable mLocClient of type LocationClient
3

There are 3 answers

2
Ayman Mahgoub On BEST ANSWER

Update to latest google-play-services (revision 12 now) from the Android SDK Manager and it will works fine.

0
bompf On

Had the same problem and setting a newer version of Play Services (4.0.30) in my build.gradle resolved the issue for me.

Don't forget to add this to your AndroidManifest.xml in case it isn't there yet:

<meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
1
Robert Fischer On

In case you didn't figure it out already, just use the latest version of the google-play-services (revision 10).