GoogleApiAvailability 错过了 firebase-messaging:9.4.0

GoogleApiAvailability missed with firebase-messaging:9.4.0

将依赖项声明为

compile 'com.google.firebase:firebase-messaging:9.4.0'

我在 activity 的导入行中收到 "can not resolve symbol GoogleApiAvailability" 消息

import com.google.android.gms.common.GoogleApiAvailability;

怎么了?

将此行添加到您的构建文件依赖项中:

compile 'com.google.android.gms:play-services-base:9.4.0'

play-services-base 是 Play Services 基础客户端库,在 Play Services Setup Guide.

中列出

我遇到了同样的问题,但就我而言,只需更改 build.gradle(Module: app) 文件中 apply plugin: 'com.google.gms.google-services' 的位置即可解决问题。

apply plugin: 'com.google.gms.google-services'

写在gradle文件的最后。从此处删除它并将其添加到顶部,apply plugin: 'com.android.application' 行下方 像这样:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

然后点击立即同步。问题已解决。

对于我的情况,只需添加此依赖项就可以了 -

implementation "com.google.android.gms:play-services-location:16.0.0

如果您使用最新的 classpath 'com.google.gms:google-services:4.3.10',要检查 Google PlayServices 可用性,您可以使用 GoogleApiAvailabilityLight