尽管gradle文件中有Google Play Services依赖项,但找不到融合的位置提供程序类

1 android google-play-services fusedlocationproviderapi

我的应用使用FusedLocationProviderApi来获取当前位置。我已经在允许我的应用程序模块的gradle文件中添加了允许应用程序使用Google Play服务的行:

compile 'com.google.android.gms:play-services-ads:11.0.2'
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试声明一个FusedLocationProvider变量时,它变成红色并且无法识别该类。我唯一的猜测是我可能应该导入该类,但我不知道具体如何。

Dan*_*ent 5

您目前仅导入广告API。

除了广告编译行之外,您还需要将其添加到build.gradle中:

implementation 'com.google.android.gms:play-services-location:16.0.0'
Run Code Online (Sandbox Code Playgroud)

要查看各个API的当前细分,请查看以下文档:https : //developers.google.com/android/guides/setup