将Firebase消息添加到扑扑的android项目时出现依赖项错误 [英] dependency error while adding firebase messaging to a flutter android project

查看:58
本文介绍了将Firebase消息添加到扑扑的android项目时出现依赖项错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Firebase消息添加到我的Flutter项目中.

I've added firebase messaging to my Flutter project.

在iOS上运行良好,尝试在Android上运行时出现错误:

Works fine on iOS, getting an error when trying to run on Android:

Android dependency 'androidx.localbroadcastmanager:localbroadcastmanager' has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath. You should manually set the same version via DependencyResolution

我的配置:

在pubspec.yaml

in pubspec.yaml

cloud_firestore: ^0.11.0+2
firebase_auth: ^0.11.1
firebase_messaging: ^5.0.1+1

在android/build.gradle中

in android/build.gradle

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

在android/app/build.gradle中

in android/app/build.gradle

implementation 'com.google.firebase:firebase-core:16.0.9'

在gradle.properties中

in gradle.properties

android.useAndroidX=true
android.enableJetifier=true

推荐答案

我使用此 answer .您可以通过在../android/build.gradle(不是../android/app/build.grade)中其他subprojects部分旁边添加以下行来解决此问题.

I fix the error using this answer. You can work around it by adding the following lines next to other subprojects sections in ../android/build.gradle (not ../android/app/build.grade).

感谢 mklim /issues/27679#issuecomment-463438749"rel =" nofollow noreferrer>解决方案.

Thanks to mklim for the solution.

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'androidx.localbroadcastmanager' &&
                    !details.requested.name.contains('androidx')) {
                details.useVersion "1.0.0"
            }
        }
    }
}

我的版本:firebase_messaging: ^5.0.4

这篇关于将Firebase消息添加到扑扑的android项目时出现依赖项错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆