Search code examples
androidcordovafirebase

Could not find any version that matches com.google.firebase:firebase-iid:[16.0.0]


I use FCM plugin in my cordova app. I get the following error after executing cordova build android in my command prompt.

Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugApkCopy'.
   > Could not find any version that matches com.google.firebase:firebase-iid:[16.0.0].
     Versions that do not match:
         11.0.4
         11.0.2
         11.0.1
         11.0.0
         10.2.6
         + 14 more
     Searched in the following locations:
         file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/google/m2repository/com/google/firebase/firebase-iid/maven-metadata.xml
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/maven-metadata.xml
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/
         file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/firebase/firebase-iid/maven-metadata.xml
         file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/firebase/firebase-iid/
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/maven-metadata.xml
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/firebase/firebase-iid/
     Required by:
         project : > com.google.firebase:firebase-messaging:17.0.0
   > Could not find any version that matches com.google.android.gms:play-services-basement:[15.0.1].
     Versions that do not match:
         11.0.4
         11.0.2
         11.0.1
         11.0.0
         10.2.6
         + 17 more
     Searched in the following locations:
         file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/google/m2repository/com/google/android/gms/play-services-basement/maven-metadata.xml
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/maven-metadata.xml
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/
         file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/android/gms/play-services-basement/maven-metadata.xml
         file:/D:/android-sdk_r24.4.1-windows/android-sdk-windows/extras/android/m2repository/com/google/android/gms/play-services-basement/
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/maven-metadata.xml
         file:/D:/ZenHelp/ZenHelp2017/platforms/android/sdk-manager/com/google/android/gms/play-services-basement/
     Required by:
         project : > com.google.firebase:firebase-messaging:17.0.0 > com.google.android.gms:play-services-tasks:15.0.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
(node:2404) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

I checked ANDROID_HOME path and its correct. I also updated my android sdk tools where my Google Play Services is updated to version 49 and Google repository to version 58. I tried with cordova clean android also.


Solution

  • open your build.gradle located at platforms/android

    and find

    allprojects {
    repositories {
        mavenCentral();
        jcenter()
     }
    }
    

    then replace it with

    allprojects {
       repositories {
          jcenter()
          maven {
             url "https://maven.google.com"
          }
       }
    }
    

    this worked for me