Compose Preview Screenshot Testing can fail in validateDebugScreenshotTest while parsing a JUnit result file with Element type "testsuite" must be followed by either attribute specifications, ">" or "/>". This is not a screenshot mismatch. Google tracked it as a tooling defect and lists the fix in Android Studio Rabbit 2 | 2026.2.2 Canary 3.
Representative error
> Task :app:validateDebugScreenshotTest FAILED
org.xml.sax.SAXParseException:
Element type "testsuite" must be followed by either attribute specifications, ">" or "/>".
The file name and line number vary. The key diagnostic is that the XML parser cannot interpret the opening <testsuite ...> element as valid XML.
Cause
The Compose Preview Screenshot Testing validation/reporting pipeline generates or consumes malformed JUnit-style XML. The parser then fails at the incomplete or corrupted <testsuite opening tag. Official Issue #479862361 tracks this as an Android Studio/AGP tooling bug, with a fixed build listed in the Rabbit 2 closed-issues page.
Important: Public official information does not identify one test name or character sequence that always causes the malformed output. Do not assume that the app UI or an individual assertion is the root cause without inspecting the generated XML.
Conditions and affected versions
- The project uses Compose Preview Screenshot Testing.
- A validation task such as
validateDebugScreenshotTestruns. - The workflow reaches the stage that reads generated JUnit XML, locally or in CI such as GitHub Actions.
The public issue does not identify the first affected build. Google lists the fix in Android Studio Rabbit 2 | 2026.2.2 Canary 3, paired with AGP 9.5.0-alpha08 and published October 1, 2026. Do not assume a stable-channel backport until Google documents one.
Recommended fix
- Preserve the failing XML: Upload
build/test-resultsand screenshot-test report output as CI artifacts. - Upgrade to a fixed toolchain: Use Android Studio Rabbit 2 | 2026.2.2 Canary 3 or later with AGP 9.5.0-alpha08 or another release documented to contain the fix. Keep Gradle, Kotlin, and Compose-related plugins within their official compatibility ranges.
- Regenerate stale output: Stop Gradle daemons, clean the build, and rerun the validation task.
./gradlew --stop
./gradlew clean
./gradlew :app:validateDebugScreenshotTest --stacktrace
- Rerun CI from a clean workspace: Disable caches that restore old
buildoutput for the first post-upgrade run, or change the cache key. - Verify XML and reports: Confirm that the JUnit XML parses and that the HTML report and comparison images are produced, not only that Gradle exits successfully.
Alternatives if Canary is not acceptable
- Temporarily pin the last Android Studio/AGP/screenshot-testing combination your team verified as working. This is not Google’s permanent fix, so reproduce it in your project first.
- Run validation in a local fixed environment while preparing the CI toolchain update and compare outputs.
- Inspect the failed XML around
<testsuite. Manual repair can confirm the diagnosis but is not durable because the file is regenerated.
Renaming tests or post-processing XML should only be a narrow workaround after proving that a particular input causes the corruption. The official issue does not establish those changes as generally valid fixes.
How to verify the fix
./gradlew :app:validateDebugScreenshotTest --stacktracecompletes without the XML parser exception.- A standard XML parser opens the generated JUnit file.
- The HTML report and expected, actual, and diff images are generated.
- The GitHub Actions or other CI workflow also succeeds from a clean workspace.
Cautions
- This occurs during screenshot-test result generation or parsing; it is not an application runtime crash.
- A successful
cleanmay only be temporary if the toolchain still lacks the fix. - Before using Canary/alpha tooling for production builds, test other AGP changes and plugin compatibility separately.
- Once XML parsing works, an ordinary screenshot mismatch may appear. Diagnose it separately.
Summary
Element type "testsuite" must be followed by either attribute specifications, ">" or "/>" means the Compose Preview Screenshot Testing workflow cannot parse its JUnit XML. Preserve the failed artifact, upgrade to the officially fixed Android Studio Rabbit 2 | 2026.2.2 Canary 3 and AGP 9.5.0-alpha08 or later, remove stale output, and rerun validation. If upgrading is not yet possible, pin a verified toolchain and do not treat hand-edited XML as a permanent solution.
