无法将 Google Places PlacePicker 导入 Android 项目

Cannot import Google Places PlacePicker into Android project

我正在尝试编写一个涉及使用 PlacePicker 捕获位置信息的简单程序。但是,我的项目似乎无法解决必要的导入问题。

build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.google.android.gms:play-services-location:9.2.0'
    compile 'com.google.android.gms:play-services-maps:9.2.0'
}

Activity:

import com.google.android.gms.location.places.Place; // "Place" is not resolved
import com.google.android.gms.location.places.ui.PlacePicker; // "ui" is not resolved
import com.google.android.gms.maps.model.LatLng;

LatLng 导入似乎有效,但其他两个无效。当我导入完整的 com.google.android.gms:play-services:9.2.0 API 时,整个项目运行良好,但我想使用特定的 API 调用来减少不必要的库。

在播放服务 9.2.0 中,places API 不再位于 location 中。这些现在处于自己的 places 依赖关系中。要解决这些问题,您应该将其添加到您的 build.gradle.

implementation 'com.google.android.gms:play-services-places:9.2.0'

已回复