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

import com.google.android.gms.location.LocationClient cannot be resolved

我正在编译 error.I 已添加 google 播放服务库 workspace.Then 已成功添加最新的 sdk(tools,extras)。

但是不知道为什么还是会出现这个错误

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);

}
}

控制台中:

我明白了,找不到与给定名称匹配的资源(在 '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>

编辑:

任何人都可以帮助我 this.Thanking 你。

更新: docs好像更新了

大约一周前我遇到了同样的问题问题是因为 GooglePlayServices 库已更新并且 LocationClientdeprecated as well (but the docs were not updated)。您一定是更新了 GooglePlayServices 库,然后才出现此错误。

因此,您需要使用 com.google.android.gms.common.api.GoogleApiClientcom.google.android.gms.location.LocationRequest[=30= 而不是使用旧的 LocationClient ].

请参阅 GoogleApiClient and LocationRequest

的文档

这是因为 LocationClient 已弃用新的 Google Play Services。而且我认为您已经使用了最新的 google 播放服务。因此,您只需将 LocationClient 更改为 GoogleApiClient,将 LocationClient 替换为最新的 Google play services,这将解决您的问题。

更多的可以访问这个Link