cordova-plugin-firebase: Error: Found item String/google_app_id more than one time

Breaking change in the new tag: “cordova-plugin-firebase”: “^0.1.24”,

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:mergeReleaseResources’.

/Users/zoltan/Developer/myProject/platforms/android/res/values/strings.xml: Error: Found item String/google_app_id more than one time

The content of strings.xml:

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="app_name">My app name</string>
    <string name="launcher_name">@string/app_name</string>
    <string name="activity_name">@string/launcher_name</string>
    <string name="google_app_id">xxxxxxx---xxxxxxx</string>
    <string name="google_api_key">xxxxxxx---xxxxxxx</string>
    <string name="google_app_id">@string/google_app_id</string>
    <string name="google_api_key">@string/google_api_key</string>
</resources>

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 23 (3 by maintainers)

Most upvoted comments

Remove this in strings.xml

<string name="google_app_id">Your API ID</string>
<string name="google_api_key">Your API KEY</string>
<string name="google_app_id">@string/google_app_id</string>
<string name="google_api_key">@string/google_api_key</string>

Work for me

Updating strings.xml or any file created during the build is not a solution it is a workaround of an issue. We need reliable repeatable builds without manually having to update files.

I made a change to the cordova-plugin-firebase/scripts/after_prepare.js so that both ios and android get copied if they both exist.

if (directoryExists(IOS_DIR)) {
    copyKey(PLATFORM.IOS);
}

if (directoryExists(ANDROID_DIR)) {
    copyKey(PLATFORM.ANDROID, updateStringsXml);
}

I removed and re-added android platform, the error( Found item String/google_app_id more than one time) disappeared.

cordova platform rm android cordova platform add android

$ cordova clean android worked here

To reproduce the issue:

  1. delete the plugins, and platform folder
  2. add the platform android
  3. add the platform ios
  4. try to build the android version

The problem is, that if the ios platform added, then the after_prepare file runs again. Also it tries:

    copyKey(PLATFORM.IOS);
} else if (directoryExists(ANDROID_DIR)) {
    copyKey(PLATFORM.ANDROID, updateStringsXml)
}

So the copyKey(PLATFORM.ANDROID, updateStringsXml) runs, it copies the keys, then in the function exception happens, so the callback function won’t be called.

I faced same problem too in 0.1.24. ~And this problem occurs only release build.~ I don’t have another plugin that is also adding google_app_id and google_api_key.