将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