Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

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

Closed
cybermill opened this issue Aug 31, 2016 · 19 comments
Closed

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

cybermill opened this issue Aug 31, 2016 · 19 comments

Comments

@cybermill
Copy link

cybermill commented Aug 31, 2016

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

  • set up android push plugin
  • set up firebase messaging
  • import the google-services.json file
  • build

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

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 macdonst added this to the Release 2.0.0 milestone Sep 5, 2016
@macdonst
Copy link
Member

macdonst commented Sep 5, 2016

@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
Copy link
Author

@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
Copy link
Author

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
Copy link
Member

Implementation notes:

  • write a hook that copies google-services.json to platforms/android
  • remove setting of google_app_id to strings.xml
  • add google services gradle plugin
  • switch push plugin logic to read sender ID from gcm_defaultSenderId

@leetheguy
Copy link

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
Copy link
Member

macdonst commented Dec 7, 2016

@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
Copy link

Javierfernandez93 commented Jan 25, 2017

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
Copy link

evereq commented Jan 26, 2017

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
Copy link

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
Copy link

kirillgroshkov commented Feb 3, 2017

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
Copy link

Javierfernandez93

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

@giladKaplan
Copy link

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

  • 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: "+"

@rickgoud
Copy link

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
Copy link

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

macdonst added a commit that referenced this issue May 25, 2017
* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Fixed empty token on android first run (#1008)

* Removed GCM files and added FCM files

* Added .framework files as custom frameworks

* Changed code to work with FCM

* Added hook and resource file to copy GoogleService-Info.plist

* fixed registration and removed unused code

* Use CocoaPods

* Fix rebase errors

* Fix topic subscription and unsubscription on FCM

* Refactor GCMIntentService to FCMService

* Issue #689: Remove sender id from PushNotification init Android options

* Issue #689: Remove sender id from PushNotification init iOS options

* 📝 Update to using fcm-node

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* Add empty google services plist

* Pin FCM to 9.8.0

* 🔧 Add browser platform back for FCM branch

* 🔨🔧⬆️ Use Babel to transpile ES2015 code

* 🔧 add tern to gitignore

* 🔖 Bumping plugin version to 2.0.0-rc1

* 2.0.0-rc1

* Updating CHANGELOG

* Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons

* 🐛🍎 Issue #1461: App crashes when initialising with topics (v2.0.0-rc1)

* 🐛🐧📝⬆️ #1460: Build Issue Android

* 🐛🍎🔧 Fixing a merge issue where aps-environment was accidentally removed

* 🐧📝🐛 Issue #1470: Cannot install phonegap-plugin-push on master

* 📝 Using a newer version on the examples

* 🍎🐛 Issue #1497: App crashes after refreshing when using FCM (v2)

* Bumping plugin version to 2.0.0-rc2

* 2.0.0-rc2

* Updating CHANGELOG

* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Removed GCM files and added FCM files

* Changed code to work with FCM

* Added hook and resource file to copy GoogleService-Info.plist

* Use CocoaPods

* Fix rebase errors

* Issue #689: Remove sender id from PushNotification init Android options

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* Pin FCM to 9.8.0

* 🔧 Add browser platform back for FCM branch

* 🔨🔧⬆️ Use Babel to transpile ES2015 code

* 🔧 add tern to gitignore

* 🔖 Bumping plugin version to 2.0.0-rc1

* 🐛🐧📝⬆️ #1460: Build Issue Android

* Bumping plugin version to 2.0.0-rc2

* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Removed GCM files and added FCM files

* Added hook and resource file to copy GoogleService-Info.plist

* Use CocoaPods

* Fix rebase errors

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* Updating CHANGELOG

* ✏️ fixing error in CHANGELOG

* Bumping plugin version to 2.0.0-rc2

* Updating CHANGELOG

* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Removed GCM files and added FCM files

* Changed code to work with FCM

* Added hook and resource file to copy GoogleService-Info.plist

* fixed registration and removed unused code

* Use CocoaPods

* Fix rebase errors

* Issue #689: Remove sender id from PushNotification init Android options

* Issue #689: Remove sender id from PushNotification init iOS options

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* 🔧 add tern to gitignore

* 🔖 Bumping plugin version to 2.0.0-rc1

* Bumping plugin version to 2.0.0-rc2

* Remove hook and use resource-file tag to copy google services file

* Add resource-file way of copying google services files

* Bump requirements

* 🔧 Update cordovaDependencies

* 🔖 Bumping plugin version to 2.0.0-rc3

* 2.0.0-rc3

* Updating CHANGELOG

* Fixes 'framework not found GoogleToolboxForMac' linker error in 2.0.0-rc3 (#1715)

* Remove unused files (#1732)

* Remove GTM framework. (#1739)
@sga-lalitesh
Copy link

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:
#1660

Please help

@robinbonnes
Copy link

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 macdonst removed the staging label Jun 28, 2017
@macdonst
Copy link
Member

Fixed in the 2.0.0 release candidates.

@kareraisu
Copy link

kareraisu commented Mar 14, 2018

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
Copy link

lock bot commented Jun 3, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests