question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error : Invalid character in entity name when &amp; is in the <name>

See original GitHub issue

Bug Report

Problem

Can not include &amp; in the cordova app name without causing a build failure to occur when strings.xml is created.

What is expected to happen?

If I have properly escaped the & in the config.xml, it should also apply to the strings.xml.

What does actually happen?

It seems the &amp; is converted back to & when strings xml is created, perhaps in prepare.js. This causes the cordova add command to fail.

Information

Given the following config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="xxx.xxx.xxxx" version="6.2.2" android-versionCode="622000062" versionCode="62" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:gap="http://phonegap.com/ns/1.0">

    <name>TIMING &amp; TRACKING</name>
    <description>
        Timing APP
    </description>

Command or Code

Run the command to create the cordova project

cordova platform add android@10.1.1
Using cordova-fetch for cordova-android@10.1.1
Adding android project...
Creating Cordova project for the Android platform:
	Path: platforms/android
	Package: me.rtrt.app.tsa
	Name: TIMING & TRACKING
	Activity: MainActivity
	Android target: android-30
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@10.1.1
Invalid character in entity name
Line: 3
Column: 37
Char:

Then, checking the strings.xml that was created, you can find there is a non-escaped &

/platforms/android/app/src/main/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- App label shown within list of installed apps, battery & network usage screens. -->
    <string name="app_name">TIMING & TRACKING</string>
    <!-- App label shown on the launcher. -->
    <string name="launcher_name">@string/app_name</string>
    <!-- App label shown on the task switcher. -->
    <string name="activity_name">@string/launcher_name</string>
</resources>

Environment, Platform, Device

N/A

Version information

Android Cordova 10.1.1 MacOs 10.15.7 (catalina)

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
pkwiatkowski0commented, Feb 3, 2022

Also looking forward for this one

7reactions
saggio89commented, Feb 2, 2022

Same, I need this fix in – is there plans to merge this pull request?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is invalid character entity &ccb - xml - Stack Overflow
This symbol has special semantics in xml in initiating an entity reference (kind of a symbolic constant) - you cannot use it in...
Read more >
Solved: XML parse tool error - Invalid character reference
Solved: Hi everyone, I am using a SOAP API and downloading different fields with mixed string/numbers data from it.
Read more >
ArcPy: Select_Analysis Invalid Characters - GIS Stack Exchange
My suggestion is to use the function to validate table names in arcpy: ... Don't know why the output name made a problem,...
Read more >
Error: Invalid character in entity name - AppStudio
When I try to “Make Native App with Voltbuilder” (run android --debug) I keep getting the error, error: Error: Invalid character in entity...
Read more >
Source code for html5lib.constants - Read the Docs
"cant-convert-numeric-entity": "Numeric entity couldn't be converted to character ... "invalid-character-in-attribute-name": "Invalid character in attribute ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found