Search code examples
androidxmlgradlebuild-error

INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified


I’m encountering an issue during my Android project build in Android Studio. The build fails with the following error:

org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
    at java.xml/com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createAttribute(Unknown Source)
    at com.android.ide.common.resources.NodeUtils.processSingleNodeNamespace(NodeUtils.java:206)
    at ...

Here are the details of my environment:

  • Gradle Version: 8.7
  • JDK Version: JetBrains Runtime 17.0.11 - aarch64
  • Platform: macOS (Pro M3)

I’ve already tried the following without success:

  • Clean project and rebuild
  • Invalidate cache and restart
  • Fresh install of Android Studio
  • Download and use local Gradle installation

Could anyone suggest a solution or help identify the root cause? It seems related to XML resources, but I couldn’t find any obvious illegal characters.

Any help would be greatly appreciated!

Thanks in advance.


Solution

  • I discovered that the issue was due to the default language of the device. It was causing an invalid character error during the build process. Changing the system language to English resolved the issue, and the build completed successfully.