Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-14262

Cordova does not allow creating and editing resource files

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 7.0.0
    • Fix Version/s: None
    • Component/s: cordova-android
    • Labels:
      None

      Description

      Hi,

      in my cordova plugin, I am trying to edit the resulting android apps `colors.xml` file. Unfortunately, by default the android app cordova creates does not have a `colors.xml` file - this means the following code does nothing, as a non existent file is simply ignored (without warning or error).

      <config-file target="./res/values/colors.xml" parent="/resources">
          <color name="my-color">#F00000</color>
      </config-file>

      What I tried instead now was first creating the file by simply copying over an empty one with the `resource-file` directive and then editing it, resulting in a plugin.xml like the following:

      <resource-file src="path/to/colors.xml" target="app/src/main/res/values/colors.xml" />
      
      <config-file target="./res/values/colors.xml" parent="/resources">
          <color name="my-color">#F00000</color>
      </config-file>

      The file is copied to the correct place, but still not modified. I am guessing that `config-file` is somehow executed earlier than `resource-file`.

      Also if I simply add my color to strings.xml, it works flawlessly - because the android app build with cordova does indeed contain a strings.xml by default.

      What I would like to achieve now is either

      a) make the `config-file` directive lazily create the colors.xml if it doesn't exist

      b) create an empty colors.xml and fill it with the `config-file` directive

       

      Any ideas are welcome!

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              tobilarscheid Tobias Larscheid
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: