Compose Preview Screenshot Testing can reject a style that builds and runs correctly in a normal Android app, reporting Cyclic style parent definitions and producing no screenshot at all. The failure occurs when a dotted style name explicitly uses parent="". Google fixed the resource-resolution bug as Issue #539672113 and lists it under Android Studio Rabbit 1 Canary 3.
Actual error
com.android.tools.screenshot.ScreenshotRenderException:
Screenshot rendering failed:
Render Problems:
- Cyclic style parent definitions:
"Modal" specifies parent "Modal.Base" implies parent "Modal"
- Too many errors (457 more errors not displayed)
The HTML report may only show empty Reference Image, Diff Image, and New Image cells. Inspect the raw JUnit XML <error> element for the real diagnostic:
module/build/test-results/validate<Variant>ScreenshotTest/
TEST-preview-screenshot-test-engine.xml
Cause
When an Android style name contains a dot and its parent attribute is absent, Android can infer the text before the final dot as the parent. An explicit parent="" means that the style has no parent and that this dotted-name inference must be disabled.
<style name="Modal.Base" parent="">
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="Modal" parent="Modal.Base" />
AAPT2 and a production app build handle this correctly. In affected Screenshot Testing versions, the distinction between an empty parent attribute and an absent parent attribute is lost between merged resources and the rendering backend. The resolver then incorrectly infers Modal as the parent of Modal.Base, inventing the cycle Modal → Modal.Base → Modal.
Trigger: Compose Preview Screenshot Testing with an AAR or module resource containing a dotted style name and explicit parent=""
Confirmed affected versions: screenshot-validation-api and screenshot-validation-junit-engine 0.0.1-alpha15 and 0.0.1-alpha16
Official fixed release listing: Android Studio Rabbit 1 | 2026.2.1 Canary 3
Recommended solutions
1. Update to Rabbit 1 Canary 3 or newer
Use Android Studio Rabbit 1 Canary 3 or a later release that contains Google’s fix, together with its compatible Compose Screenshot Testing components. Because Canary is a preview channel, validate existing golden images and CI behavior in a separate branch before adopting it broadly.
2. Add a dot-free intermediate style when you cannot update
The workaround confirmed in the official issue is to replace the empty parent with an explicit, non-empty parent whose name contains no dot:
<style name="ModalNoParent" />
<style name="Modal.Base" parent="@style/ModalNoParent">
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="Modal" parent="Modal.Base" />
The non-empty name survives resource processing, so the renderer does not enter its incorrect dotted-name fallback. Treat this as a temporary workaround and verify that it does not alter the library’s public theme behavior.
How to diagnose the failure
- Run
validate<Variant>ScreenshotTestorscreenshotTest<Variant>. - Check whether every image cell in the HTML report is empty.
- Search the JUnit XML for
ScreenshotRenderExceptionandCyclic style parent definitions. - Inspect the merged-resource
merger.xmland confirm that the original style still containsparent="". - Build and run the app normally. If that succeeds, the screenshot renderer’s false cycle detection is more likely than an actual theme cycle.
./gradlew :module:validateDebugScreenshotTest --stacktrace
grep -R "Cyclic style parent definitions" module/build/test-results/validateDebugScreenshotTest
Alternatives
- If you own the affected AAR, publish a temporary version that uses the intermediate-style workaround.
- If the style comes from a third-party dependency, prefer updating the test tooling instead of modifying the dependency’s packaged resources.
- You can temporarily exclude only the affected previews to keep CI moving, but record the scope and removal date because those previews will no longer detect visual regressions.
How to verify the fix
./gradlew :module:updateDebugScreenshotTest
./gradlew :module:validateDebugScreenshotTest
Confirm that validation passes, image cells are populated in the HTML report, the cycle message is gone from the JUnit XML, and the app’s runtime theme remains unchanged.
Important notes
parent=""is valid Android resource syntax. Removing it blindly can re-enable implicit dotted-name inheritance and change the actual theme hierarchy.- Hundreds of repeated lines do not necessarily represent hundreds of independent cycles. The same resource-resolution failure can be repeated for many preview render attempts.
- Rabbit 1 Canary 3 is a preview build. Check the closed-issues page for the exact stable release you intend to adopt.
Summary
Cyclic style parent definitions: "Modal" specifies parent "Modal.Base" implies parent "Modal" is a false positive caused by the Screenshot Testing renderer losing an explicit empty parent on a dotted style name. Updating to Rabbit 1 Canary 3 or newer is the preferred fix. Until then, an explicit dot-free intermediate parent prevents the incorrect fallback inheritance.
