无法找到符号变量" LocationServices"在GoogleApiClient实例中?

时间:2016-11-29 03:46:34

标签: java android google-maps google-location-services

我是GeoFencing的新用户,我正在尝试向GoogleApiClient实例添加API。但它显示的错误就像无法找到变量LocationServices。 这是我的代码:

private void createGoogleApi() {
    Log.d(TAG, "createGoogleApi()");
    if ( googleApiClient == null ) {
        googleApiClient = new GoogleApiClient.Builder( this )
                .addConnectionCallbacks( this )
                .addOnConnectionFailedListener( this )
                .addApi(LocationServices.API)
                .build();
    }
}

我的gradle是

 compile 'com.google.android.gms:play-services-maps:9.8.0'

清单文件

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
 <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="Server_key" />

你能不能看看这个。或者你可以提供一些其他的文档或链接供参考。谢谢

3 个答案:

答案 0 :(得分:0)

在gradle中添加播放服务位置

dependencies {
compile 'com.google.android.gms:play-services-location:9.8.0'
}

检查完所有更新后,在SDK中完成。

答案 1 :(得分:0)

我认为你错过了这样的事情:

{{1}}

供进一步参考see here

答案 2 :(得分:0)

您只需在应用级别build.gradle文件

中添加以下行
compile 'com.google.android.gms:play-services:10.0.1'