【问题标题】:LocationClient setMockMode and setMockLocation are not defined?LocationClient setMockMode 和 setMockLocation 没有定义?
【发布时间】:2013-08-09 01:42:34
【问题描述】:

一直在使用 android 地理围栏,但测试正在成为一个问题。我需要模拟设备位置以触发进入/离开事件,但到目前为止我无法找到这样做的方法。

在 LocationClient 的文档中,有两种方法似乎可以满足我的需要:

但我无法使用这些方法编译任何项目,因为编译器抱怨这些符号不存在:

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

【问题讨论】:

    标签: android mocking android-geofence location-client


    【解决方案1】:

    从 Android SDK 管理器更新到最新的 google-play-services(现在是第 12 版),它会正常工作。

    【讨论】:

    • 问题是谷歌存储库还没有最新的库版本。我报告了这一点,最新版本(rev. 3)包含正确的库。因为我使用了 repo(通过 gradle)而不是直接使用库,所以我遇到了这个问题。
    • 您可以从 Android SDK Manager 下载最新版本的 google-play-services 库项目,然后将其导入到 eclipse 项目中。
    【解决方案2】:

    如果您还没有弄清楚,请使用最新版本的 google-play-services(修订版 10)。

    【讨论】:

    • 我安装了最新的 google-play-services 修订版 (10),但仍然出现此编译错误。
    【解决方案3】:

    遇到同样的问题,在我的 build.gradle 中设置更新版本的 Play Services (4.0.30) 为我解决了这个问题。

    不要忘记将其添加到您的AndroidManifest.xml,以防它还没有:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-05
      • 1970-01-01
      • 2021-04-28
      • 2013-09-25
      • 1970-01-01
      • 2018-09-28
      相关资源
      最近更新 更多