microsoft / appcenter-sdk-cordova

App Center Preview SDK for Cordova
http://appcenter.ms
MIT License
52 stars 27 forks source link

build failed - Cannot add extension with name 'googleServices', as there is an extension already registered with that name. (cordova-plugin-firebasex compatibility) #130

Open Solomakha-Dmytro opened 4 years ago

Solomakha-Dmytro commented 4 years ago

Im install cordova-plugin-appcenter-push@0.5.1, and already have cordova-plugin-firebasex@6.0.7 in my project. And have error when trying to build android apk.

ERROR:

  • Where: Script 'C:\software\rep\veo.mobile\projects*appname\platforms\android\cordova-plugin-appcenter-push*appname-AppCenterPush.gradle' line: 14

  • What went wrong: A problem occurred evaluating project ':app'.

    Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin'] Cannot add extension with name 'googleServices', as there is an extension already registered with that name.

Now im have the same code in /platforms/android/cordova-plugin-appcenter-push/appname-AppCenterPush.gradle:

buildscript {
    repositories {
        google()
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

ext.postBuildExtras = { 
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

and /platforms/android/cordova-plugin-firebasex/appname-build.gradle:

buildscript {
    repositories {
        google()
        maven {
            url "https://maven.fabric.io/public"
        }
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "io.fabric.tools:gradle:1.30.0"
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}
repositories {
    mavenCentral()
    maven {
        url "https://maven.google.com"
    }
}

cdvPluginPostBuildExtras.add({
    // Use class instead of id (string) to be able to apply plugin from non-root gradle file
    apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
    apply plugin: com.crashlytics.tools.gradle.CrashlyticsPlugin

    // Enable Crashlytics NDK reporting
    crashlytics {
        enableNdk true
    }
})

Repro Steps

Please list the steps used to reproduce your issue.

  1. Install cordova-plugin-firebasex@6.0.7
  2. install cordova-plugin-appcenter-push@0.5.1
  3. run cordova compile android

Details

  1. Which SDK version are you using? 0.5.1

  2. What version of Cordova, Cordova platforms? Cordova version 9.0.0 Installed platforms: android 8.0.0 ios 5.0.1

  3. What third party plugins are you using?

annakocheshkova commented 4 years ago

Hey! I'll consult with the team we'll see what we can do, but on the first look I can't say for sure if that's something that can be fixed, looks like a valid conflict.

saikirangit commented 4 years ago

But out of curiosity why would you need 2 plugins that supports same push feature ? Shouldn’t you use only one of them.?

dannyf620 commented 3 years ago

you must remove all dependencies that use Google services from the package.json file, run npm install, then install each library again. in my case I had two "Firebase Analytics" and "Firebase crashlytics", with that there is congruence in the version of the packages.