dependency error while adding firebase messaging to a flutter android project

1,406

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

Share:
1,406
user6097845
Author by

user6097845

Updated on December 11, 2022

Comments

  • user6097845
    user6097845 over 1 year

    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