为什么我无法导入 com.google.android.gms.location.LocationListener;和 LocationRequest,还有 LocationServices?
why i can't import com.google.android.gms.location.LocationListener; and LocationRequest, also LocationServices?
我正在尝试使用使用直接用户位置的 android 工作室构建一个 android 应用程序,但我在导入 com.google.android.gms.location.LocationListener 时遇到错误;它说它无法解析符号 'LocationListener',还有 'LocationRequest' 和 'LocationServices' 我试着寻找答案,但我无法弄清楚问题是什么。
尝试添加以下内容:
compile 'com.google.android.gms:play-services:9.8.0'
在您的应用级别 gradle 依赖项和
classpath 'com.google.gms:google-services:3.1.0'
在项目级别 gradle 依赖关系
请注意,版本可能会根据您的 SDK 配置或您的偏好而改变
查看此 link 以获得 Google 播放库的列表,您可以添加位置库。
https://developers.google.com/android/guides/setup
implementation 'com.google.android.gms:play-services-location:11.6.0'
这应该可以解决。
自 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
。
我正在尝试使用使用直接用户位置的 android 工作室构建一个 android 应用程序,但我在导入 com.google.android.gms.location.LocationListener 时遇到错误;它说它无法解析符号 'LocationListener',还有 'LocationRequest' 和 'LocationServices' 我试着寻找答案,但我无法弄清楚问题是什么。
尝试添加以下内容:
compile 'com.google.android.gms:play-services:9.8.0'
在您的应用级别 gradle 依赖项和
classpath 'com.google.gms:google-services:3.1.0'
在项目级别 gradle 依赖关系
请注意,版本可能会根据您的 SDK 配置或您的偏好而改变
查看此 link 以获得 Google 播放库的列表,您可以添加位置库。
https://developers.google.com/android/guides/setup
implementation 'com.google.android.gms:play-services-location:11.6.0'
这应该可以解决。
自 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
。