7

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.

Deepak Thakur
  • 3,453
  • 2
  • 37
  • 65

2 Answers2

15

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

Peter Wilson
  • 4,150
  • 3
  • 35
  • 62
  • I faced the same issue. This answer resolved it. Can you please explain why we have to update this particular file? Also, now when I take an android build for the app, it does not get installed. Unfortunately, 'APPNAME' has stopped error is being shown. – Smokey Jun 13 '18 at 11:28
  • 1
    more explanation is found here https://stackoverflow.com/a/46467800/4183947 – Peter Wilson Jun 13 '18 at 12:35
0

I followed the next steps:

At FCMPlugin.gradle I have commented the following line:

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

then edit ProjectName/plugins/cordova-plugin-fcm/plugin.xml:

<framework src="com.google.firebase:firebase-core:11.8.0" />
<framework src="com.google.firebase:firebase-messaging:11.8.0" />

This works for me.

Credit: ghosteye on Ionic forum (He did an ionic cordova platform remove android and then ionic cordova platform add android@~6.4.0 but it wasn't necessary for me).

Hope it helps.

Demy
  • 1
  • 3