Compose Preview Screenshot Testing can stop rendering with “Cyclic style parent definitions” even when the Android resource styles contain no real cycle. Google tracked a false positive triggered by a dotted style name combined with an explicit parent="", and fixed it in Android Studio Rabbit 1 Canary 3 with AGP 9.5.0-alpha03.
Representative error
Cyclic style parent definitions
Style: AppTheme.Component.Card
parent=""
The style and task names vary by project. The distinctive case occurs in the Compose Preview Screenshot Testing renderer and involves a dot-separated style name with an empty explicit parent.
Cause
Dots in Android style names can imply a parent hierarchy, while parent="" explicitly requests no parent. The affected screenshot-test renderer handled that combination incorrectly and reported a cycle that did not exist.
A genuine mutual parent relationship can produce the same diagnostic. Inspect the relevant styles.xml entries first and rule out a real A→B→A cycle.
Affected conditions and versions
- Compose Preview Screenshot Testing is enabled
- A style has a dotted name such as
AppTheme.Component.Card - The same style explicitly declares
parent="" - The project uses a screenshot-testing/Android Studio toolchain from before the fix
The officially confirmed fix ships with AGP 9.5.0-alpha03 in Android Studio Rabbit 1 Canary 3.
Recommended fix
- Where preview tooling is acceptable, update to Android Studio Rabbit 1 Canary 3 or later and AGP 9.5.0-alpha03 or later.
- Check compatibility for the Gradle Wrapper, JDK, and Compose Screenshot Testing plugin.
- Remove stale test outputs and rerun the screenshot test.
plugins {
id("com.android.application") version "9.5.0-alpha03" apply false
}
./gradlew --stop
./gradlew clean
./gradlew validateDebugScreenshotTest --stacktrace
Alternatives when preview tooling is unavailable
As a temporary workaround, rename the affected style to use underscores instead of dots and update every reference. This can avoid implicit parent inference.
<style name="AppTheme_Component_Card" parent="">
<item name="android:padding">8dp</item>
</style>
If the design permits, removing the explicit empty parent is another possibility. However, the dotted name may then inherit an implicit parent and change rendering, so compare the resulting screenshots before accepting either workaround.
How to verify the fix
- Identify the style and parent declaration named in the diagnostic.
- Confirm that no real cyclic parent chain exists.
- After updating, rerun the same Preview Screenshot Test.
- Compare the reference and newly rendered images to ensure that a workaround did not alter theme inheritance.
Important notes
AGP 9.5.0-alpha03 contains the official fix but is a preview release. A stable CI pipeline may prefer a narrowly scoped style-name workaround until a fixed stable version is adopted. Do not assume every occurrence is a false positive without checking the actual parent graph.
Summary
If “Cyclic style parent definitions” appears only for a dotted style name with parent="" in Compose Preview Screenshot Testing, it is likely this known false positive. Upgrade to AGP 9.5.0-alpha03 or later, or temporarily adjust the style name or parent declaration and verify the rendered result.
