【问题标题】:why i can't import com.google.android.gms.location.LocationListener; and LocationRequest, also LocationServices?为什么我不能导入 com.google.android.gms.location.LocationListener;和 LocationRequest,还有 LocationServices?
【发布时间】:2017-11-16 17:42:52
【问题描述】:
我正在尝试使用使用直接用户位置的 android studio 构建一个 android 应用程序,但在 import com.google.android.gms.location.LocationListener 时出现错误;它说它无法解析符号“LocationListener”,对于“LocationRequest”和“LocationServices”,我尝试寻找答案,但无法弄清楚问题所在。
【问题讨论】:
标签:
java
android
google-maps
location
【解决方案1】:
尝试添加以下内容:
compile 'com.google.android.gms:play-services:9.8.0'
在您的应用级别的 gradle 依赖项和
classpath 'com.google.gms:google-services:3.1.0'
在项目级别的 gradle 依赖项中
请注意,版本可能会根据您的 SDK 配置或您的偏好而改变
【解决方案2】:
自 2018 年和 Gradle 3.0.0 以来,情况发生了变化。现在你必须使用:
implementation 而不是 compile,在您的 ./app/build.gradle 中,在 dependencies{} 部分。像这样:
dependencies {
...
implementation 'com.google.android.gms:play-services-location:16.0.0'
...
}
在releases 网页中搜索location。