config.xml Mistakes

Common config.xml Mistakes and How to Debug Them

Most config.xml mistakes surface in cordova prepare, often tersely. Three, each made on a copy of BookNest:

Three broken config.xml files and what cordova prepare saysXML
# 1: a typo in an edit-config target, target="/manifest/applicaton"
cordova prepare android
# 2: <content src="index.html"> left unclosed
cordova prepare android
# 3: id="com.example.book-nest", on a clone that has no platforms/ yet
cordova prepare android
Output
Unable to graft xml at selector "/manifest/applicaton" from ".../AndroidManifest.xml" during
  config install
Unhandled error. ('Parsing .../config.xml failed')
...
Error validating package name. Must look like: `com.company.Name`. Currently is:
  `com.example.book-nest`

The first names the selector, so check its spelling against the real AndroidManifest.xml. The second gives no line number, but any XML parser does: python3 -c "import xml.dom.minidom as m; m.parse('config.xml')" ends with ExpatError: mismatched tag: line 25, column 2, the line where </widget> met the open <content>. The third is an application ID rule: segments may hold letters, digits and underscores, but not hyphens.

The quieter mistakes do not fail at all:

cordova prepare android --verbose (The Build Pipeline) shows each merge step, and the merged platform config.xml (Identity and Preferences) shows what the runtime reads.