【问题标题】:Failed to resolve implementation 'com.google.firebase:firebase-messaging:15.0.2'无法解决实施“com.google.firebase:firebase-messaging:15.0.2”
【发布时间】:2018-06-08 11:58:24
【问题描述】:

我正在为一个版本集成 Firebase 消息传递是:

'com.google.firebase:firebase-messaging:15.0.2' 

我的类路径是:-

classpath 'com.google.gms:google-services:3.2.0'

我遇到了以下错误:-

无法解决:firebase-messaging 打开文件

【问题讨论】:

    标签: android firebase android-studio firebase-cloud-messaging google-play-services


    【解决方案1】:

    改变这个:

    classpath 'com.google.gms:google-services:3.2.0'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    

    进入这个:

    classpath 'com.google.gms:google-services:4.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'
    

    说明:

    在这种情况下,使用firebase-messaging:15.0.2google-services:4.0.1 会起作用,因为最重要的是更新3.2.0 上方的google-services,这是因为需要google-services:3.3.0 才能使用firebase 库15.0 及以上版本。您可以查看此blog post。这解释了 Firebase 库版本控制的变化。

    但最好还是更新google-services 插件以防止其他依赖项出现任何其他错误。

    注意:

    低于15.0.0的版本在google maven仓库中,所以你可以在gradle中使用它们。但是,您不能将版本 15.0.0 与低于 15.0.0 的版本混合使用并使用谷歌播放服务 4.0.1,正如我在回答 here 中所说的那样。这就是为什么最好将 Firebase 库更新到最新版本的原因。

    【讨论】:

    • 只是好奇,如果更新到classpath 'com.google.gms:google-services:4.0.1' 也可以工作吗?根据 maven.google.com,应该有 15.0.2 版本的 firebase-messaging
    • 是的,我认为15.0.2 可以与4.0.1 一起使用,但最重要的是更新3.2.0 以上的google-services,因为需要google-services 3.3.0 才能使用firebase 库从 15.0 及更高版本开始。但无论如何,当我回答这个问题时,我使用了google-services 和 firebase 库的最新版本,以防止他使用其他 firebase 库时出现任何其他问题。 @智乔
    • 此外,maven.google.com 仅列出了 google() repo 中的所有库,还有一些 firebase 库(如 firebase-auth)的 9.0 版,但如果您将其与google-services:4.0.1(无论如何都不要使用它,因为它很旧)。 @智乔
    • 酷。感谢您的跟进。很高兴这成功了。需要注意的是,由于这是跨主要版本(即 15.0.2 => 17.0.0)的更新,它可能会引入破坏 API 的更改。
    • @ZhiQiao yes just to add 小于15.0.0的版本在google maven repo里,他可以用。但是,他不能将 15.0.0 版本与低于 15.0.0 的版本混合使用 google play services 4.0.1(如本答案所述:stackoverflow.com/questions/50732704/…)。这就是为什么最好在 Firebase 库发布后将它们更新到最新版本的原因。也是,当然,他需要在更新后查看发行说明。
    【解决方案2】:

    根据帖子2上的Guy4444 1我已经改变了

    implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'

    implementation 'com.google.firebase:firebase-messaging:17.0.0'

    它解决了问题!

    【讨论】:

      【解决方案3】:

      我通过更改解决了它

      这个

      implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
      

      到这里

       implementation 'com.google.firebase:firebase-messaging:17.0.0'
      

      【讨论】:

        猜你喜欢
        • 2019-03-30
        • 1970-01-01
        • 2023-04-10
        • 2020-05-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-10
        相关资源
        最近更新 更多