EddyVerbruggen / cordova-plugin-googleplus

:heavy_plus_sign: Cordova plugin to login with Google Sign-In on iOS and Android
566 stars 625 forks source link

Conflict - failed to build android APK with cordova push plugin #571

Open cmohanraj10 opened 5 years ago

cmohanraj10 commented 5 years ago

Code :

<plugin name="phonegap-plugin-push" spec="2.1.2"></plugin>

<plugin name="cordova-plugin-googleplus" spec="5.2.1"> <param name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.183313231191-2mkjb9f85gasdasdasdaius5478h9fedc"/> <param name="PLAY_SERVICES_VERSION" value="11.0.1"/> </plugin>

<preference name="phonegap-version" value="cli-8.0.0"/>

Getting this error if we build this plugin with push plugin.

`Execution failed for task ':app:processReleaseGoogleServices'.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.0.1.`

brodriguezs commented 5 years ago

Hi, I have the same problem, the solution is set the right versions of Google play services plugin, and the correspondent Firebase versions, there is the versions recommended in the firebase guide: https://firebase.google.com/docs/android/setup. So, I used "FCM with updated dependencies" plugin but I guess that applies as well for other plugins that use Google services and firebase plugins as well.

So at first with this google plus plugin I have to set the google play services to 16.0.0 in the config.xml file:

<plugin name="cordova-plugin-googleplus" spec="7.0.0">
         <variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.0000" />                         
          <variable name="PLAY_SERVICES_VERSION" value="16.0.0" />
 </plugin>

After that, I updated, the build.gradle (root of project) with:

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

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:4.2.0'
    }   
}

allprojects {
    repositories {
        google()
        maven {
            url "https://maven.google.com"
        }   
        jcenter()
    }
    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="27.0.1" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4                                                                
      defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default                                                         
      defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default                                                  
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

and in the build.gradle file of the plugin in conflict (FCM with dependencies updated v2.4 https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated) with:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.+'
        //classpath 'com.google.gms:google-services:3.1.+'
    }
}
repositories {
    mavenCentral()
    jcenter()
}
dependencies {
    //compile 'com.google.firebase:firebase-core:10.+'
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
}
 apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
//apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Having in mind that I changed that in the origin folder plugin, and after the change, I did:

ionic cordova platform rm android && ionic cordova platform add android

And that's all, following the Firebase guidance about the right COMPATIBLE versions, I got that works fine for me after a bunch of days of research and a friend (Android Native) advice.

pschinis commented 5 years ago

I was having this same issue and I figured out it was because the plugin was using play services version 11.8.0 even though I had set the "PLAY_SERVICES_VERSION" to the correct version in the config file.

It finally worked for me after removing the plugin and then adding it back but this time I included the PLAY_SERVICES_VERSION variable when I added the plugin to cordova.

The command that worked for me (after removing the plugin):

cordova plugin add cordova-plugin-googleplus --save --variable 
REVERSED_CLIENT_ID=your_reversed_client_id --variable WEB_APPLICATION_CLIENT_ID=your_web_client_id -- 
variable PLAY_SERVICES_VERSION=your_required_play_services_version