Random thoughts & observations

From the mundane to the profound and everything in between here’s what’s rocking our world

Resolving Ionic App invalid character entity warning on Android

Posted: April 7, 2016
Written by: Saints At Play
Category: Ionic Framework

Here's an interesting error we came across when publishing a recent App to an Android device:

Error happened [Error: Invalid character entity
Line: 4
Column: 56
Char:  ]
Error: Invalid character entity
Line: 4
Column: 56
Char:  
    at error (/usr/local/lib/node_modules/ionic/node_modules/xml2js/node_modules/sax/lib/sax.js:642:8)
    at strictFail (/usr/local/lib/node_modules/ionic/node_modules/xml2js/node_modules/sax/lib/sax.js:662:22)
    at Object.write (/usr/local/lib/node_modules/ionic/node_modules/xml2js/node_modules/sax/lib/sax.js:1336:11)
    at Parser.exports.Parser.Parser.parseString (/usr/local/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:403:31)
    at Parser.parseString (/usr/local/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:6:61)
    at Object.exports.parseString (/usr/local/lib/node_modules/ionic/node_modules/xml2js/lib/xml2js.js:433:19)
    at /usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/config-xml.js:23:12
    at /usr/local/lib/node_modules/ionic/node_modules/ionic-cordova-lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16
    at fs.js:336:14
    at /usr/local/lib/node_modules/ionic/node_modules/ionic-cordova-lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:42:10

Yikes!

If you are currently encountering this error you will not believe how (thankfully) simple the solution to fixing this is...

Locate your config.xml file at the root of your Ionic/Cordova project and double check the name and description fields for any non-encoded entities.

Initially we had something akin to the following in the description field:

iOS & Android App for locating restaurants & cafes in London

See the problem?

Yep - the ampersands aren't entity encoded. So if we change that to the following:

iOS & Android App for locating restaurants & cafes in London

Save the file and, with your Android device connected to the computer, run the following command from the Terminal (assumes you are at the root of your project):

ionic run android

Then your App should build and publish to the device without that error being triggered now.

Any other errors though and you're on your own there!

« Return to Posts

Comments

There are no comments

Posting comments after three months has been disabled.