Skip to content

fix(gradle-9): unable to resolve class XmlParser for Groovy 4.x#1896

Open
erisu wants to merge 1 commit intomasterfrom
fix/gradle-xmlparser
Open

fix(gradle-9): unable to resolve class XmlParser for Groovy 4.x#1896
erisu wants to merge 1 commit intomasterfrom
fix/gradle-xmlparser

Conversation

@erisu
Copy link
Member

@erisu erisu commented Feb 26, 2026

Platforms affected

n/a

Motivation and Context

Fix unable to resolve class XmlParser:

Script '/Users/cordova/testProject/platforms/android/CordovaLib/cordova.gradle' line: 135

Could not compile script '/Users/cordova/testProject/platforms/android/CordovaLib/cordova.gradle'.
> startup failed:
  script '/Users/cordova/testProject/platforms/android/CordovaLib/cordova.gradle': 135: unable to resolve class XmlParser 
   @ line 135, column 12.
         return new XmlParser(false, false).parseText(xml)
                ^
  
  1 error

Description

Added following import to cordova.gradle

import groovy.xml.XmlParser

While this is unconfirmed, I beleive the XmlParser was originally was located in groovy.util.XmlParser and was deprecated and removed in 4.0.0. The new location for the XmlParser parser is groovy.xml.XmlParser which also existed in version 3.0.0.

I believe its safe to add this import to resolve the issue for Gradle 9.0 (Groovy 4) and continue to support Gradle 8.0 (Groovy 3).

Testing

  • npm t
  • platform add
  • build android
  • Open project in Android Studio Panda 1 without first build.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.43%. Comparing base (6b17223) to head (81c6dc5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1896   +/-   ##
=======================================
  Coverage   61.43%   61.43%           
=======================================
  Files          24       24           
  Lines        4922     4922           
=======================================
  Hits         3024     3024           
  Misses       1898     1898           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erisu erisu changed the title fix(gradle): unable to resolve class XmlParser for Groovy 4.x fix(gradle-9): unable to resolve class XmlParser for Groovy 4.x Feb 26, 2026
Copy link
Contributor

@GitToTheHub GitToTheHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works now everything, when the platform is added and cordova prepare is called after. When I just add the platform by cordova platform add and open it in Android Studio Panda 1, I get the error: Invalid Gradle JDK configuration found.:

Image

When I do cordova prepare before opening the project, this error is only showed sometimes, but I always get the warning:

Bildschirmfoto 2026-02-26 um 13 07 02

When I do cordova build before opening the project in Android Studio Panda 1, I get no warnings and errors.

@GitToTheHub
Copy link
Contributor

Would it make sense to automatically call cordova build after the android platform was added?

@erisu erisu added this to the 15.0.1 milestone Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants