android - import com.google.android.gms.location.LocationClient无法解析

标签 android google-maps

<分区>

我遇到了这个编译错误。我在同一工作区中添加了 google play 服务库。然后成功添加了最新的 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);

}
}

控制台中:

我明白了,找不到与给定名称匹配的资源(在“值”处,值为“@integer/google_play_services_version”)。

list :

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

编辑:

enter image description here

enter image description here

任何人都可以帮我解决这个问题。谢谢。

最佳答案

更新:docs现在好像更新了。

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

因此,您需要使用 com.google.android.gms.common.api.GoogleApiClient 而不是使用旧的 LocationClient 和 < strong>com.google.android.gms.location.LocationRequest

请参阅 GoogleApiClient 的文档和 LocationRequest

关于android - import com.google.android.gms.location.LocationClient无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28017931/

相关文章:

android - Web View 不加载重定向 url

javascript - 如何使用 jQuery.inArray() 检查另一个数组中是否找到字符串元素数组?

javascript - Http 站点未检测到 Chrome 中的位置 - 问题

javascript - 谷歌地图javascript多种方法错误

android - 使用GIGYA登录,无需任何社交服务提供商

android - 以编程方式自定义 SearchView

java - 如何记录 rxJava2 的所有异常的堆栈跟踪?

安卓工作室 : Gradle failed to resolve Dependencies

javascript - Google map 反向地理编码仅返回 "APPROXIMATE"位置

Android - 谷歌地图 v2 - 需要更新设备上的谷歌播放服务