PlaceAutocompleteFragment无法解析 [英] PlaceAutocompleteFragment can't resolved

查看:62
本文介绍了PlaceAutocompleteFragment无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我添加了Google Maps,它们可以正常工作.我想添加一个PlaceAutocompleteFragment.我使用的是已经为地图生成的密钥,并且启用了google.console中的Places Api选项.我已经将它们添加到我的build.gradle中:

In my app I have added Google Maps and they work fine. I want to add a PlaceAutocompleteFragment. I am using the key which I had already generate for maps and I have enable the option Places Api from google.console. I have added these to my build.gradle:

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

但是当我尝试使用PlacesAutoCompleteFragment时,Android Studio无法解决此问题.

but when I try to use PlacesAutoCompleteFragment then Android Studio can't resolve this.

推荐答案

此处的问题是PlaceAutocompleteFragment在Google Play服务的8.3版中不存在.

The problem here is that PlaceAutocompleteFragment didn't exist in version 8.3 of Google Play Services.

此文档的记录不很理想,但是您可以在此博客PlaceAutocompleteFragment是在2015年12月宣布"的.

This isn't documented very well, but you can see on this blog that PlaceAutocompleteFragment was "announced" in December 2015.

您还可以在其中看到 GitHub上的PlaceCompleteFragment Google代码示例,它们正在使用8.4版的GooglePlayServices.

You can also see in the PlaceCompleteFragment Google code samples on GitHub that they are using version 8.4 of GooglePlayServices.

我也遇到了这个问题,而更新Google Play服务才使它起作用.

I also had this problem, and updating Google Play Services is what made it work.

因此,请在SDK Manager中更新Google Play服务,然后像这样修改build.gradle,它应该可以工作:

So, update Google Play Services in the SDK Manager, and then modify the build.gradle like so, and it should work:

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

更新

在较新版本的Google Play服务中,他们破解了Google Places API,因此,除了地图和位置信息之外,您还需要包括它:

In newer versions of Google Play Services, they have broken out the Google Places API, so you need to include it in addition to Maps and Location:

compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile 'com.google.android.gms:play-services-places:11.0.2'

这篇关于PlaceAutocompleteFragment无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆