user6097845
user6097845

Reputation: 1437

dependency error while adding firebase messaging to a flutter android project

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

Upvotes: 2

Views: 1445

Answers (2)

dmodin
dmodin

Reputation: 21

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

Upvotes: 2

user6097845
user6097845

Reputation: 1437

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

Upvotes: 0

Related Questions