phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Strings.xml google_app_id conflict with google-services.json #1188

Closed cybermill closed 7 years ago

cybermill commented 8 years ago

Expected Behavior

App compiles, Push notifications work, angels sing, the crowds rejoice

Actual Behavior

I get an error with gradle. Error: Duplicate resources I've traced the issue to the Strings.xml google_app_id which conflicts with the values.xml that gets generated from the google-services.json If I comment out the strings.xml line <!--string name="google_app_id">1234567890123456</string--> then all compiles.

Reproduce Scenario (including but not limited to)

Google is making developers move from the cloud services to firebase-messaging. When setting this up, google generates a google-services.json file which gets put at the base of the project.

Steps to Reproduce

android I'm compiling in Android Studio 2.1.3

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

N/A

Cordova CLI version and cordova platform version

cordova --version                                    6.3.0
cordova platform version android          android 5.2.1

Plugin version

cordova plugin version | grep phonegap-plugin-push:

phonegap-plugin-push 1.8.0 "PushPlugin"

Sample Push Data Payload

      {
        "pn_gcm": {
            "data": "Test message to android!"
        }
    }

Sample Code that illustrates the problem

Logs taken while reproducing problem

:processDebugGoogleServices Parsing json file: /Users/jeffwalters/Documents/phonegap apps/pushnotification/platforms/android/google-services.json :generateDebugResources :mergeDebugResources Error:Error: Duplicate resources :mergeDebugResources FAILED Error:Execution failed for task ':mergeDebugResources'.

[string/google_app_id] /Users/jeffwalters/Documents/phonegap apps/pushnotification/platforms/android/res/values/strings.xml [string/google_app_id] /Users/jeffwalters/Documents/phonegap apps/pushnotification/platforms/android/build/generated/res/google-services/debug/values/values.xml: Error: Duplicate resources Information:BUILD FAILED

macdonst commented 8 years ago

@cybermill yeah, FCM is not support by this plugin. It will be part of the 2.0.0 release which you can check out right now in the v2.0.x branch. Try that version and let me know if the problem still exists.

cybermill commented 8 years ago

@macdonst: Ahhh. Thought it must be something like that. I was puzzled by the lack of chatter about it in the issues forum. I'll check out the 2.0 version after the holiday and provide some feedback.

Great job with the plug-in. I used it with the iOS app and it works brilliantly.

Thanks so much for all you do.

cybermill commented 8 years ago

here is the latest. The 2.0.x branch worked, but only after I commented out the strings.xml google_app_id as described in my bug report. If you do that, I have it working on my samsung device so hurray!

Thanks for your help on this macdonst.

macdonst commented 8 years ago

Implementation notes:

leetheguy commented 7 years ago

I've never had to install a branch version like this before. I tried googling and couldn't figure it out. How do I get version 2.0.0 into my app?

macdonst commented 7 years ago

@leetheguy install via the github url:

cordova plugin add https://github.com/phonegap/phonegap-plugin-push#v2.0.x

I should have a release candidate out in npm sometime this week.

Javierfernandez93 commented 7 years ago

add the next lines to "config.xml" file or just replace the spec version to "2.0.0-rc2"

<plugin name="phonegap-plugin-push" spec="2.0.0-rc2">
      <param name="SENDER_ID" value="XXXXXXXXX" />
</plugin>

then try to install $ cordova plugin add phonegap-plugin-push

evereq commented 7 years ago

Hi, v2.0.0-rc2 fails for me with another exception during cordova build process:

cordova build --release android
FAILURE: Build failed with an exception.

* Where:
Script 'D:\customer\platforms\android\phonegap-plugin-push\customer-push.gradle' line: 12

* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > For input string: "[9"

I have following plugins installed:

com.googlemaps.ios 2.1.1 "Google Maps SDK for iOS"
com.phonegap.plugins.nativesettingsopener 1.3 "Native settings"
cordova-custom-config 3.1.2 "cordova-custom-config"
cordova-plugin-appsee 2.3.11 "Appsee"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5-dev "Console"
cordova-plugin-crosswalk-webview 2.1.0 "Crosswalk WebView Engine"
cordova-plugin-device 1.1.4-dev "Device"
cordova-plugin-dialogs 1.3.0 "Notification"
cordova-plugin-firebase 0.1.18 "Google Firebase Plugin"
cordova-plugin-geolocation 2.4.1-dev "Geolocation"
cordova-plugin-globalization 1.0.4 "Globalization"
cordova-plugin-google-analytics 1.7.2 "Google Universal Analytics Plugin"
cordova-plugin-googlemaps 1.4.0 "phonegap-googlemaps-plugin"
cordova-plugin-hotline 0.6.1 "Hotline plugin for Phonegap"
cordova-plugin-intercom 3.0.19 "Intercom"
cordova-plugin-mixpanel 2.2.1 "Mixpanel"
cordova-plugin-network-information 1.3.1-dev "Network Information"
cordova-plugin-request-location-accuracy 2.2.0 "Request Location Accuracy"
cordova-plugin-splashscreen 4.0.1 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-vibration 2.1.3 "Vibration"
cordova-plugin-whitelist 1.3.1-dev "Whitelist"
cordova.plugins.diagnostic 3.3.2 "Diagnostic"
ionic-plugin-deploy 0.6.5 "IonicDeploy"
ionic-plugin-keyboard 2.2.1 "Keyboard"
me.tonny.cordova.plugins.multidex 0.1.0 "Cordova Multi Dex"
phonegap-plugin-push 2.0.0-rc2 "PushPlugin"
urbanairship-cordova 6.3.0 "Urban Airship"

Any ideas?

Javierfernandez93 commented 7 years ago

i had a lot of issues with phonegap-plugin-push, nowadays i have been working with "onesignal native plugin" for push notifications are great and free!, it's easy to work. Tell me if you want more information.

kirillgroshkov commented 7 years ago

Having same problem as @evereq:

* Where:
Script '/Users/kirill/Idea/NCApp/platforms/android/phonegap-plugin-push/cordova-push.gradle' line: 12

* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [id 'com.google.gms.google-services']
   > For input string: "+"

Using 2.0.0-rc2

lluisnieto commented 7 years ago

Javierfernandez93

Did the trick. BTW, i needed to upgrade my Cordova up to 6.4.0 to allow that plugin version be installed.

giladKaplan commented 7 years ago

hi @kirillgroshkov, what did you do? did you manage to so solve the problem

rickgoud commented 7 years ago

Hi @kirillgroshkov and @macdonst ; we have the same problem:

Failed to apply plugin [id 'com.google.gms.google-services'] For input string: "+"

Is there already a fix or workaround for this now?

Thanks!

Javierfernandez93 commented 7 years ago

@rickgoud You must to change the + string to stable version i actually works on 9.8.0 for all google services

sga-lalitesh commented 7 years ago

I tried all the version of phonegap-plugin-push but still facing the issue: `A problem occurred evaluating root project 'android'.

Failed to apply plugin [id 'com.google.gms.google-services'] For input string: "+"`

Ionic Info Cordova CLI: 7.0.1 Ionic Framework Version: 2.0.0-rc.4 Ionic CLI Version: 2.2.1 Ionic App Lib Version: 2.2.0 Ionic App Scripts Version: 1.3.7 ios-deploy version: Not installed ios-sim version: Not installed OS: macOS Sierra Node Version: v8.0.0 Xcode version: Not installed

Phonegap plugins phonegap-plugin-push 2.0.0-rc2 "PushPlugin"

I followed this link to install push notification https://docs.ionic.io/services/push/#setup

Using this command: cordova plugin add phonegap-plugin-push --variable SENDER_ID=12341234 --save

I am facing duplicate app id issue: https://github.com/phonegap/phonegap-plugin-push/issues/1660

Please help

robinbonnes commented 7 years ago

For me, com.google.gms.google-services was already installed, so I could remove from /platforms/android/phonegap-push-plugin/[appname]-push.gradle:

cdvPluginPostBuildExtras << {
    apply plugin: 'com.google.gms.google-services'
}

Seems like the 'apply plugin' gradle command needs some check if 'plugin' doesn't already exist.

macdonst commented 7 years ago

Fixed in the 2.0.0 release candidates.

kareraisu commented 6 years ago

Hi @macdonst , sorry to bother again.

I'm getting bit by this (duplicate resources for google_app_id and google_api_key) using version 2.1.3 of the plugin (cordova-android 6.4.0). The only way I can build is deleting the lines under "res/values/strings.xml" key in android.json. But then the plugin never registers (the registration handler is never called) and I am guessing it has to do with this, because it did before.

I am using the following plugins:

    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-device" spec="^1.1.7" />
    <plugin name="cordova-plugin-splashscreen" spec="^4.1.0" />
    <plugin name="cordova-plugin-ionic-webview" spec="^1.1.16" />
    <plugin name="cordova-plugin-badge" spec="^0.8.7" />
    <plugin name="cordova-plugin-local-notification" spec="~0.9.0-beta.2" />
    <plugin name="phonegap-plugin-push" spec="2.1.3">
        <variable name="FCM_VERSION" value="11.6.2" />
        <variable name="SENDER_ID" value="XXXXXX" />
    </plugin>

Any suggestions would be much appreciated!

lock[bot] commented 6 years ago

This thread has been automatically locked.