fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
624 stars 990 forks source link

Execution failed for task ':processDebugGoogleServices' #350

Open VinuOye opened 6 years ago

VinuOye commented 6 years ago

FAILURE: Build failed with an exception.

please help me out from this issue........

THis is happening when both plugins google plus and fcm are using in an app. Both are very implement for every application.

thanks in andvance.

gitSambhal commented 6 years ago

I am also getting the same error.

smkamranqadri commented 6 years ago

same here too.

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 9.0.0.

wojtek1150 commented 6 years ago

+1

vancelopes commented 6 years ago

+1

I don't have much time left, and I was holding on to this lib because the other ones are too old and too hard to manage for both platforms at the same time.

vancelopes commented 6 years ago

I managed to make a workaround for this issue.

First of all, I changed all of my google libraries (on android project) to version 10.2.1. Maps and base libs are set to force their versions:

    compile("com.google.android.gms:play-services-location:10.2.1") { force = true; }
    compile("com.google.android.gms:play-services-base:10.2.1") {
        force = true;
    }
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.google.firebase:firebase-core:10.2.1'
    compile 'com.google.firebase:firebase-messaging:10.2.1'

Still on app's gradle file, put apply plugin: 'com.google.gms.google-services' to the bottom of the file.

After syncing, I went to MainActivity.javaand changed the onCreate method to this:

    public void onCreate(Bundle savedInstanceState)
    {

        FirebaseApp.initializeApp(getApplicationContext());
        super.onCreate(savedInstanceState);
        ...
    }

This makes the 10.2.1 version of Firebase recognize your app's context, linking the API keys and initializing FCM securely.

Tested on my app and both plugins (push notifications and maps) are working great. Must work for another Google Services too.

I had forked this plugin to update FCM libs and it helps the first step above, so feel free to use it.

rabee1981 commented 6 years ago

+1

usama-ayub commented 6 years ago

Step 1 (for FCM Plugin)

Comment out these lines in the FCMPlugin.gradle file.

classpath 'com.google.gms:google-services:3.0.0' apply plugin: com.google.gms.googleservices.GoogleServicesPlugin

Step 2 (for FCM Plugin)

Change the plugin.xml of the FCM plugin.

framework src="com.google.firebase:firebase-core:9.8.0" framework src="com.google.firebase:firebase-messaging:9.8.0"

Step 3 (for Cordova-googlemap)

framework src="com.google.android.gms:play-services-maps:9.0.0" framework src="com.google.android.gms:play-services-location:9.0.0"

Step 4

Remove and re-add plattform.

Step 5 (build.gradle file of the android platform folder)

Add this line to the classpath section classpath 'com.google.gms:google-services:3.1.0'

dependencies { compile fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START debugCompile(project(path: "CordovaLib", configuration: "debug")) releaseCompile(project(path: "CordovaLib", configuration: "release")) compile "com.google.android.gms:play-services-maps:9.8.0" compile "com.google.android.gms:play-services-location:9.8.0" compile "com.google.firebase:firebase-core:9.8.0" compile "com.google.firebase:firebase-messaging:9.8.0" // SUB-PROJECT DEPENDENCIES END } And add this line below the dependencies, nearly at the bottom of the file apply plugin: 'com.google.gms.google-services'

i found this solution and also thanks @troovers

LucasBSC commented 6 years ago

Hi @usama-ayub, followed these steps and get stucked on same error:

I noticed that my dependencies on the step 5 are diferent check it out, mainly both com.google.android.gms. How can I managed to get it equal to yours?

dependencies { implementation fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START implementation(project(path: "CordovaLib")) compile "com.google.firebase:firebase-core:9.8.0" compile "com.google.firebase:firebase-messaging:9.8.0" compile "com.google.android.gms:play-services-maps:9.0.0" compile "com.google.android.gms:play-services-location:9.0.0" compile "com.onesignal:OneSignal:3.7.1" // SUB-PROJECT DEPENDENCIES END } apply plugin: 'com.google.gms.google-services'

Did it really work for you? I mean, do you have both plugin buildable plugin installed (Maps & FCM)?

usama-ayub commented 6 years ago

@LucasBSC can you send me build.gradle file

LucasBSC commented 6 years ago

buildgradle.txt @usama-ayub sure, follows the file attached.

I managed to get the versions equal to yours. But on the STEP 3 (Google Maps) I forced the version to 9.8.0 instead of 9.0.0 as you pointed. So the APK was built successfully but the notifications

I try to send does not come for all devices, it goes for only one specified Samsung S8 phone. Don't know whats happening at all.

juanmendez commented 6 years ago

There is a great solution for Firebase. One google-services.json file is needed declaring all your flavors as apps. https://medium.com/@Miqubel/multiple-build-types-in-firebase-on-android-6f6715f6dd83

rizkyfaramita commented 6 years ago

I fixed the problem by changing classpath 'com.google.gms:google-services:3.2.0' to classpath 'com.google.gms:google-services:3.0.0'

exhesham commented 6 years ago

I uncommented the gms (exclude group: "com.google.android.gms") and it solved everything:

    compile (project(':react-native-camera')) {
            exclude group: "com.android.support"

            // uncomment this if also com.google.android.gms:play-services-vision versions are conflicting
            // this can happen if you use react-native-firebase
            exclude group: "com.google.android.gms"
        }
jayasharma commented 6 years ago

In platforms > android > cordova-plugin-fcm > app-FCMPlugin.gradle

In platforms > android > build.gradle

IF REQUIRED :

In plugins > cordova-plugin-fcm > plugin.xml to

  • remove and add the android platform again and redo the steps above.