The library com.google.firebase:firebase-iid is be

2020-08-09 04:34发布

问题:

I started to get this error today, yesterday everything worked fine, there was no changes in gradle or firebase version

The library com.google.firebase:firebase-iid is being requested by various other libraries at [[17.0.0,17.0.0]], but resolves to 16.2.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

I saw that yesterday was update in google-services plugin, probably that is causing the problem.

How to fix this problem?

回答1:

I had the same issue. A quick fix would be to disable the strict version checking that is causing this problem. Add

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

at the very bottom of your app build.gradle file.



回答2:

I had the same issue. I solved it by updating firebase messaging to the last version(at this time).

implementation 'com.google.firebase:firebase-messaging:17.0.0'

to

implementation 'com.google.firebase:firebase-messaging:17.3.4'

and it is resolved(without side effect)



回答3:

For me disabling version check did not solve the problem. What I did is to exclude firebase-iid module from firebase messaging library and add it separately

implementation ("com.google.firebase:firebase-messaging:17.3.4"){
        exclude group: 'com.google.firebase', module: 'firebase-iid'
    }

implementation 'com.google.firebase:firebase-iid:17.0.3'


回答4:

If you had this problem you might see a lot of posts saying that you can disable this check. I don't like doing that because it hides the problem.

After a while I finally understood it was saying that some library was asking for a version I didn't have. So I added this in the build/app/build.gradle and it built

implementation "com.google.firebase:firebase-iid:17.0.2"

Just use the version it says it resolves to, in your case 16.2.0.



回答5:

I had a similar error with 'com.google.firebase:firebase-iid using these firebase dependencies:

  1. implementation 'com.google.firebase:firebase-core:16.0.7'
  2. implementation 'com.google.firebase:firebase-messaging:17.3.4'
  3. implementation 'com.google.firebase:firebase-database:16.0.6'
  4. implementation 'com.crashlytics.sdk.android:crashlytics:2.9.6'
  5. implementation 'com.google.firebase:firebase-functions:16.1.3'

after adding

  • implementation 'com.google.firebase:firebase-analytics:16.3.0'

it went away.



回答6:

I got the same error today. I'm using react-native-firebase and react-native-push-notification. Running ./gradlew :app:dependencies I saw that react-native-push-notification was requiring the latest version of com.google.firebase:firebase-messaging, which in turn was requiring com.google.firebase:firebase-iid:[17.0.0], causing the error.

I manually specified an earlier version of firebase-messaging for react-native-push-notification as described here. That fixed the problem for me:

// in android/build.gradle

ext {
    firebaseVersion = '17.1.0' // add this line
    // ...
}


回答7:

This solved mine. So you can try it out. Add

googleServices { disableVersionCheck = true }

to app\build.gradle



回答8:

For me it was the build.gradle file in node_modules/@aws-amplify/pushnotification (the same applies for the build.gradle file in react-native-push-notification)

change the version numbers of firebase packages to match what you have in your own app/build.gradle file.

For me that was

compile 'com.google.firebase:firebase-messaging:17.6.0' compile 'com.google.firebase:firebase-core:16.0.8'



回答9:

  • add the latest cordova-android platform (v8.0.0)

    ionic cordova platform add android@latest

  • add my fork of this plugin

    ionic cordova plugin add cordova-plugin-firebasex

  • add plugin to enable AndroidX in the project

    ionic cordova plugin add cordova-plugin-androidx

  • add plugin to patch existing plugin source

ionic cordova plugin add cordova-plugin-androidx-adapter

  • build!

    ionic cordova build android

It's 100% works



回答10:

While I was setting up FCM android client from Android Studio assistant, and it was somehow only adding some old versions of fcm in my gradle file, I copy pasted exact-latest version from the android developers website itself, Then the error went on its own. Hope this helps someone facing similar issue.



回答11:

For Android Studio Users Only

I had the same issue. and this is added after apply plugin: 'com.google.gms.google-services' com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

at the very bottom of your app build.gradle file and my problem was solved

 apply plugin: 'com.google.gms.google-services' 

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true


回答12:

I had the same issue but I solved it by updating all my firebase dependencies to the latest ones.

// Firebase
    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-auth:18.1.0'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'

    implementation 'com.firebaseui:firebase-ui-firestore:5.0.0'
    implementation 'com.firebaseui:firebase-ui-storage:5.0.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'


回答13:

I had a similar issue, but with the error message;

Dependency failing: com.google.firebase:firebase-messaging:17.0.0 -> com.google.firebase:firebase-iid@[16.0.0], but fire base-iid version was 19.0.0.

and resolved it by using the following versions in App-level build.gradle;

// Google Firebase
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-messaging:19.0.1'


回答14:

I got the same issue when integrating 'firebase-analytics'.

Original code:

implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-analytics:17.0.0'

Solved by code:

implementation 'com.google.firebase:firebase-core:16.0.4 '
implementation 'com.google.firebase:firebase-analytics:16.0.0'

change the 'firebase-analytics' version the same level with 'firebase-core'



回答15:

The version increase of firebase-messaging is essentially correct, but just in case people see this going forward, I recommend seeing Current Android Release Notes to keep all of your firebase libraries up to date.

The issue is that if you implement one library that requires other Firebase libraries to run, and you add a second with the same dependencies but on later versions, you lose compatibility.

As of present time, Google has gotten much better at not releasing breaking or incompatible versions of new libraries. Use the latest of each and you should be fine.



回答16:

I updated my firebase messaging version and it solved my problem.

Before

implementation 'com.google.firebase:firebase-messaging:17.6.0'

updated

implementation 'com.google.firebase:firebase-messaging:20.0.1'



回答17:

I think I am late here to answer this but maybe this solution will solve someone's problem.

In build.gradle updating com.google.gms:google-services:4.0.0to com.google.gms:google-services:4.3.3 solved my issue.



回答18:

If upgrading all the com.google.firebase libraries doesn't fix the issue, try upgrading the google services plugin dependency at com.google.gms:google-services.



回答19:

I got the same issue. Issue resolved by updating latest firebase-messaging version from https://firebase.google.com/support/release-notes/android

From

implementation 'com.google.firebase:firebase-messaging:19.0.0'

to

implementation 'com.google.firebase:firebase-messaging:19.0.1'

I do not know why build error was occurring all on a sudden. It seems weird but When I updated the firebase-messaging version, issue resolved.