导入com.google.android.gms.location.LocationClient无法解析

Luf*_*ffy 4 android google-maps

我收到了这个编译错误.我在同一个工作区中添加了google play服务库.然后成功添加了最新的sdk(工具,附加组件).

但我不知道为什么这个错误仍然会发生.

import com.google.android.gms.location.LocationClient;  -->import cannot be resolved


public class Main extends Activity implements
        GooglePlayServicesClient.ConnectionCallbacks,
        GooglePlayServicesClient.OnConnectionFailedListener {

private LocationClient mLocationClient;   --->LocationClient cannot be resolved to a type


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    mLocationClient = new LocationClient(this, this, this);

}
}
Run Code Online (Sandbox Code Playgroud)

控制台中:

我得到这个,找不到与给定名称匹配的资源(在'value'处,值为'@ integer/google_play_services_version').

表现:

 <uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="21" />

   <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

........
</application>
Run Code Online (Sandbox Code Playgroud)

编辑:

在此输入图像描述

在此输入图像描述

任何人都可以帮助我.谢谢你.

SMR*_*SMR 6

更新:文档现在似乎被更新.

我有一个星期左右了同样的问题以前的问题是,因为GooglePlayServices库更新,也将LocationClient弃用,以及(但该文档未更新).您必须更新GooglePlayServices库,然后发生此错误.

所以不要使用旧的,LocationClient你需要使用com.google.android.gms.common.api.GoogleApiClientcom.google.android.gms.location.LocationRequest.

请参阅GoogleApiClientLocationRequest的文档