【发布时间】:2020-02-12 07:35:20
【问题描述】:
我的 PlaceAutoComplete 搜索栏在被点击时失去焦点。有时可以点击并搜索,但它没有找到任何地方,然后再次失去焦点。
我已经尝试遵循此处提供的解决方案:Android Google Places API, getAutocompletePredictions returns status 'PLACES_API_ACCESS_NOT_CONFIGURED'
我有一个包含 Google 地图片段和 Google 地方片段的活动:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity"
android:orientation="vertical"
android:weightSum="1">
<fragment
android:id="@+id/place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
我在我的 google 开发者控制台中启用了 Google Places:
当然,我正在使用 API 密钥,并且由于 Google 地图功能正常工作,它已正确完成:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
可能是依赖问题吗? 我的相关依赖项:
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.libraries.places:places-compat:2.2.0'
我添加了places-compat(最后一个依赖项)只是因为有人建议它,但它没有帮助。
什么可能导致这个问题?谢谢
【问题讨论】:
标签: android android-studio google-location-services