问题
I've added firebase messaging to my Flutter project.
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
My configuration:
in pubspec.yaml
cloud_firestore: ^0.11.0+2
firebase_auth: ^0.11.1
firebase_messaging: ^5.0.1+1
in android/build.gradle
classpath 'com.google.gms:google-services:4.2.0'
in android/app/build.gradle
implementation 'com.google.firebase:firebase-core:16.0.9'
in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
回答1:
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
).
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"
}
}
}
}
my version: firebase_messaging: ^5.0.4
回答2:
Well, the answer was found here: https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
followed this section: "Manually migrate your app", specifically step 2 helped to sort this out
来源:https://stackoverflow.com/questions/56294812/dependency-error-while-adding-firebase-messaging-to-a-flutter-android-project