fechanique / cordova-plugin-fcm

Google FCM Push Notifications Cordova Plugin
623 stars 995 forks source link

google service version issue. #306

Open bsjaffer opened 7 years ago

bsjaffer commented 7 years ago

Suddenly getting this error when i run in android please suggest

Found com.google.firebase:firebase-core:+, but version 9.0.0 is needed for the google-services plugin.                                                                                                             
Found com.google.firebase:firebase-messaging:+, but version 9.0.0 is needed for the google-services plugin.                                                                                                        
:processDebugGoogleServices FAILED                                                                                                                                                                                 

FAILURE: Build failed with an exception.                                                                                                                                                                           

* What went wrong:                                                                                                                                                                                                 
Execution failed for task ':processDebugGoogleServices'.                                                                                                                                                           
> 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.googl
e-services/) or updating the version of com.google.android.gms to 9.0.0.                                                                                                                                           

* Try:                                                                                                                                                                                                             
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.                                                                                                     

BUILD FAILED                                                                                                                                                                                                       

Total time: 51.444 secs                                                                                                                                                                                            
Error: cmd: Command failed with exit code 1 Error output:                                                                                                                                                          
FAILURE: Build failed with an exception.                                                                                                                                                                           

* What went wrong:                                                                                                                                                                                                 
Execution failed for task ':processDebugGoogleServices'.                                                                                                                                                           
> 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.googl
e-services/) or updating the version of com.google.android.gms to 9.0.0.                                                                                                                                           

* Try:                                                                                                                                                                                                             
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.                                                                                                     
larssn commented 7 years ago

Same, just started... at a not very convenient time :P

romiohasan commented 7 years ago

+1 no fix yet.

` FAILURE: Build failed with an exception.


Build was working fine until this release from yesterday ( May 16, 2017 ) : https://bintray.com/android/android-tools/com.google.gms.google-services/3.1.0

larssn commented 7 years ago

A fix that seems to progress the build process further is:

Change the file src/android/FCMPlugin.gradle, and change the dependency:

classpath 'com.google.gms:google-services:+' to classpath 'com.google.gms:google-services:2.1.2' Update, set it to classpath 'com.google.gms:google-services:3.0.0' You have to remove/add the platform for this to work.

Update: Removed the error that v2.1.2 threw.

larssn commented 7 years ago

Update: Updated the above example

Ok the actual fix is: Use the strategy above, but set the dependency to 3.0.0, like so: classpath 'com.google.gms:google-services:3.0.0'

larssn commented 7 years ago

Remember to remove the platform, and readd.

bsjaffer commented 7 years ago

It works for me too, but every time we need to change this ? are this is only for temporary purpose.

larssn commented 7 years ago

Temporary hopefully

lp1bp commented 7 years ago

@larssn Thanks so much for the fix ! I did a PR for fechanique with your fix (I didn't see one with this change) https://github.com/fechanique/cordova-plugin-fcm/pull/309

jessmarkpanadero commented 7 years ago

Thanks @larssn for the fix.

kurtnovice commented 7 years ago

Thanks. Fixed my problem.

vidareversa commented 7 years ago

Thanks, u save me

danielschiau commented 7 years ago

also remember to remake resources :)

rehanhanar7 commented 7 years ago

Hi may I know what is the exact fix ??

Below is my project.properties file

target=android-23 android.library.reference.1=CordovaLib cordova.gradle.include.1=cordova-plugin-badge/usc-badge.gradle cordova.system.library.1=com.android.support:support-v4:+ cordova.system.library.2=com.google.firebase:firebase-core:+ cordova.system.library.3=com.google.firebase:firebase-messaging:+ cordova.gradle.include.2=cordova-plugin-fcm/usc-FCMPlugin.gradle cordova.system.library.4=com.squareup.okhttp3:okhttp:3+

The below is the dependancy in Build.gradle file of PROJECT_NAME/platforms/android/build.gradle file

dependencies { classpath 'com.android.tools.build:gradle:1.5.0' }

Below is the issue i get :

Can anyone tell me what is exact fix ???

After reading the above posts I did the following change in project.properties file. Build becomes successful but the App crashes.

target=android-23 android.library.reference.1=CordovaLib cordova.gradle.include.1=cordova-plugin-badge/usc-badge.gradle cordova.system.library.1=com.android.support:support-v4:+ cordova.system.library.2=com.google.firebase:firebase-core:9.0.0 cordova.system.library.3=com.google.firebase:firebase-messaging:9.0.0 cordova.gradle.include.2=cordova-plugin-fcm/usc-FCMPlugin.gradle cordova.system.library.4=com.squareup.okhttp3:okhttp:3+

Can anyone tell me what to do in the above config file to fix the build issue and that app should run withouty crash.

lp1bp commented 7 years ago

@rehanhanar7 : Well you can either edit your own cordova-plugin-fcm files to implement @larssn 's fix (it's a one-line change) or use a fork of fechanique's repository with the fix (https://github.com/lp1bp/cordova-plugin-fcm for instance) while you wait for a PR to be approved/merged

rehanhanar7 commented 7 years ago

@lp1bp Thanks Man !!! The plugin link which you gave works fine. Try to Commit the same in this plugin. I guess this will be the temporary solution

  1. Remove the FCM plugin
  2. Add the plugin with this command "cordova plugin add https://github.com/lp1bp/cordova-plugin-fcm"
lp1bp commented 7 years ago

@rehanhanar7 : You're welcome, I'll keep my fork as up to date as possible since we're using it in production on a few hundreds of devices :)

ohyou commented 7 years ago

Note: if you're using firebase, make sure to set the Google Services version (3.0.0) in all firebase plugins as well.

cmgustavo commented 7 years ago

The solution above doesn't work on iOS (10.3.1):

*** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in GoogleService-Info.plist or set in the customized options.'

Update: Seems to be an issue with cordova-ios v4.4.0. I just installed a previous version (v4.2.1) and it 's working again.

dferreira1 commented 7 years ago

there's a lot of PR to be accepted, but the owner got lost since january. I've tried the @lp1bp fork and it's working now.

Thank you @lp1bp and @larssn!

elewin commented 7 years ago

Ive tried the above fix, but now get:

FAILURE: Build failed with an exception.

Any ideas? It builds and launches fine when I remove the plugin entirely

AlluHariRapra commented 7 years ago

@elewin i think you are used 2.1.2 change to classpath 'com.google.gms:google-services:3.0.0' and remove and re add platform . Try

Theerthagiri commented 7 years ago

Same issue for me also, its not working...

:transformResourcesWithMergeJavaResForDebug FAILED

FAILURE: Build failed with an exception.

BUILD FAILED

reddysant commented 7 years ago

Same for me also... Not working

reddysant commented 7 years ago

Worked. Thanks @lp1bp

ysayita commented 7 years ago

@lp1bp can you make your solution compliant with IOS versions less then 10 using the solution here: https://github.com/fechanique/cordova-plugin-fcm/issues/247#issuecomment-281119246

lp1bp commented 7 years ago

@ysayita Isn't it working with these changes ? https://github.com/lp1bp/cordova-plugin-fcm/commit/0f23b5344ec781bbac20155efc60f6b4bde8654a It's working for me on ios <10

ysayita commented 7 years ago

@lp1bp it seems like it is working but we cannot acquire FCM token with the version you provided on ios <10. So it does not receive the notifications. Removing lines 111 and 165 as suggested on https://github.com/fechanique/cordova-plugin-fcm/issues/247#issuecomment-281119246 causes it to stop working with ios 10 too.

lp1bp commented 7 years ago

@ysayita : I'm using my fork of the plugin on iOS 9.3 and it works well, did you try to use both onTokenRefresh and getToken ?

hortonelectric commented 7 years ago

+99 been waiting for a fix forever, nothing is working for me.

ysayita commented 7 years ago

@lp1bp thanks for your support. Using both onTokenRefresh and getToken bindings resolved the problem. Your code successfully works on IOS 9.3.5 now.

lp1bp commented 7 years ago

@ysayita You're welcome ! I'm glad it works now

snstarosciak commented 7 years ago

Unfortunately, I'm still running into this issue :/

My app-FCMPlugin.gradle file looks like this:

buildscript {
    repositories {
            jcenter()
            mavenLocal()
        }
    dependencies {
        classpath 'com.android.tools.build:gradle:+'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}
// 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

yet I'm still getting this error:

* What went wrong:
Execution failed for task ':processArmv7DebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version if available https://bintray.com/adnroid/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0

As I've been researching this problem, I've noticed that the task is very similar minus the Armv7 part. Could that be an Android Studio issue maybe? I mean, I've installed pretty much every single plugin for Android Studio so I'm not sure. Does anyone have any insight here?

hortonelectric commented 7 years ago

There's a fork of this repo that fixes it. Look that up and then replace the official plugin name with he github url in your config xml file

On Jul 19, 2017 5:49 AM, "Stevie Starosciak" notifications@github.com wrote:

Unfortunately, I'm still running into this issue :/

My app-FCMPlugin.gradle file looks like this:

buildscript { repositories { jcenter() mavenLocal() } dependencies { classpath 'com.android.tools.build:gradle:+' classpath 'com.google.gms:google-services:3.0.0' } } // 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

yet I'm still getting this error:

As I've been researching this problem, I've noticed that the task is very similar minus the Armv7 part. Could that be an Android Studio issue maybe? I mean, I've installed pretty much every single plugin for Android Studio so I'm not sure. Does anyone have any insight here?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fechanique/cordova-plugin-fcm/issues/306#issuecomment-316208320, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUzRZs2psbr3jyRy0qMVI59o6jnQJKcks5sPShRgaJpZM4NdnMY .

mfcd commented 7 years ago

After upgrading to v2.1.2, On ionic build android we are getting

FAILURE: Build failed with an exception.

* Where:
Script '/ff-client-app/platforms/android/cordova-plugin-fcm/clientapp-FCMPlugin.gradle' line: 11

* What went wrong:
A problem occurred evaluating script.
> Plugin with id 'com.google.gms.google-services' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Not sure how to proceed. Maybe there's an SDK component missing? In our Docker file, the sections that cover android sdk setup are:

#########################################################
#ANDROID STUFF
#########################################################
RUN echo ANDROID_HOME="${ANDROID_HOME}" >> /etc/environment && \
    dpkg --add-architecture i386 && \
    apt-get update && \
    apt-get install -y --force-yes expect ant wget libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 qemu-kvm kmod && \
    apt-get clean && \
    apt-get autoclean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    cd /opt && \
    wget --output-document=android-sdk.tgz --quiet http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz && \
    tar -xvf android-sdk.tgz && \
    chown -R root. /opt 

#########################################################
# Install phantomjs, otherwise npm -g fails
#########################################################
# RUN npm install -g phantomjs-prebuilt

#########################################################
# Setup environment
#########################################################
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:/opt/tools:/opt/gradle/gradle-3.3/bin

#########################################################
# Install sdk elements
#########################################################
COPY tools /opt/tools
RUN chmod +x /opt/tools/android-accept-licenses.sh && \
    chmod +x /opt/tools/android-sdk-install.sh
RUN ["/opt/tools/android-accept-licenses.sh","android update sdk --all --no-ui --filter platform-tools,tools,build-tools-23.0.2,android-23,android-24,android-25,extra-android-support,extra-android-m2repository,extra-google-m2repository"]
RUN unzip ${ANDROID_HOME}/temp/*.zip -d ${ANDROID_HOME}

The app package.json file is:


{
  "name": "XXX",
  "version": "1.0.8",
  "description": "XXX",
  "dependencies": {
    "gulp": "^3.5.6",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0",
    "gulp-sass": "^2.0.4"
  },
  "devDependencies": {
    "bower": "^1.3.3",
    "gulp-replace": "^0.5.4",
    "gulp-util": "^2.2.14",
    "ip": "^1.1.4",
    "jasmine-core": "^2.5.1",
    "karma": "^1.3.0",
    "karma-firefox-launcher": "^1.0.0",
    "karma-jasmine": "^1.0.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "shelljs": "^0.3.0",
    "xcode": "^0.8.9",
    "yargs": "^6.6.0"
  },
  "cordovaPlugins": [
    "cordova-plugin-geolocation",
    "cordova-plugin-whitelist",
    "cordova-plugin-crosswalk-webview",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "cordova-plugin-fcm",
    "uk.co.workingedge.phonegap.plugin.launchnavigator",
    "cordova-plugin-x-toast",
    {
      "variables": {
        "FABRIC_API_KEY": "XXX",
        "FABRIC_API_SECRET": "XXX"
      },
      "locator": "cordova-fabric-plugin@1.1.1",
      "id": "cordova-fabric-plugin@1.1.1"
    },
    "cordova-plugin-device",
    "cordova-plugin-network-information",
    "cordova-plugin-inappbrowser",
    {
      "variables": {
        "APP_ID": "XXX",
        "APP_NAME": "XXX"
      },
      "locator": "cordova-plugin-facebook4",
      "id": "cordova-plugin-facebook4"
    },
    "cordova-plugin-screen-orientation",
    {
      "variables": {
        "BRANCH_KEY": "XXX",
        "URI_SCHEME": "XXX"
      },
      "locator": "branch-cordova-sdk",
      "id": "branch-cordova-sdk"
    }
  ],
  "cordovaPlatforms": [
    "ios",
    "android"
  ]
}
dferreira1 commented 7 years ago

I've changed to cordova-plugin-firebase. It's more complete and developing active.

The changes are minimal to switch.

christianwico commented 7 years ago

Same old, same old.

After running:

$ ionic cordova plugin remove cordova-plugin-fcm
$ ionic cordova plugin add https://github.com/lp1bp/cordova-plugin-fcm
$ ionic cordova build android
* What went wrong:
Execution failed for task ':processDebugGoogleServices'.
> 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.
victorhugorch commented 7 years ago

Same error. Any resolution resolve this problem yet.

cmgustavo commented 7 years ago

I had to do a fork: https://github.com/cmgustavo/cordova-plugin-fcm

ghost commented 7 years ago

I was hoping that your fork would do the trick, but did not seem to rectify the problem.

After running, cordova plugin add https://github.com/cmgustavo/cordova-plugin-fcm cordova build android I got the following: What went wrong: A problem occurred configuring root project android. Cannot add task :processDebugGoogleServices' as a task with that name already exists.

I am attempting to use Firebase Analytics (cordova-plugin-firebase-analytics) which requires Google Services (cordova-support-google-services) and Firebase Cloud Messaging. The cordova-plugin-fcm includes Google Services 3.0.0 and the cordova-support-google-services has Google Services at 3.1.0 creating the conflict.

I am new to using Ionic 3/Angular 4. A fix I had found on a different forum and implemented was changing the version in platforms/android/cordova-support-google-services to 3.0.0 from 3.1.0. But this is a temporary fix, and a Sr. Dev on my team said this was terrible and should never be done.

What is the fix for this?

ianlintner-wf commented 7 years ago

Right now there is no true "fix" because of different versions of google libraries & firebase plugins. You can fix it for your versions, but due to the velocity of development of Android, Google Services, Ionic, Cordova and the plugins themselves keeping everything cutting edge and up to date would require a unified dev team rather than the community support.

If you make changes by adding, removing, updating plugins or updating versions of ionic it will likely break again. I have had these issues from the day I used any of the Google plugins.

This is an issue with almost ALL of the google and firebase plugins across the board for Cordova and ionic.

Either update them by hand or write scripts using regex/string replace against the generated files to make sure the version numbers stay in sync.

MarinoRaul commented 6 years ago

Any solutions about this?

zeeshananjumjunaidi commented 6 years ago

make sure you already installed Google Repository in Android SDK Manager image

then simply install FCM plugin. copy google-services.json file to root project folder.

Prudhvirajdandi commented 6 years ago

compile "com.facebook.android:facebook-android-sdk:4.+" compile "com.google.firebase:firebase-core:11.0.+" compile "com.google.android.gms:play-services-auth:+" compile "com.google.android.gms:play-services-identity:+" if Change this to this.. compile "com.facebook.android:facebook-android-sdk:4.+" compile "com.google.firebase:firebase-core:11.0.+" compile "com.google.android.gms:play-services-auth:11.0.+" compile "com.google.android.gms:play-services-identity:11.0.+"

while building its changing to previous one ..could any help me on this please

noor07 commented 6 years ago

In my opinion, you should stop using fcm, developers are facing issues every time, instead of that, use Phonegap push plugin. it is far better and no conflict issue too.

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.