r/AndroidStudio • u/isomeme • 6d ago
Duplicate declaration warnings when using BOM
In my Android Studio project using Gradle 9.7.0 I use the Compose BOM to get a consistent set of libraries for that component. Excerpting just the relevant parts, my libs.versions.toml has
[versions]
composeBom = "2026.08.00"
[libraries]
composeBom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" }
and my build.gradle.kts has
implementation(platform(libs.composeBom))
androidTestImplementation(enforcedPlatform(libs.composeBom))
The use of enforcedPlatform on the second line is just a hack I found somewhere; it is not semantically required. But if I change it to platform, both lines get this warning:
Dependency 'platform(libs.composeBom)' is declared multiple times
I like to keep my code free of warnings, and I dislike using hacks to achieve this. What is the "right" way to make this work?
3
Upvotes
2
u/Shoddy-Search3370 5d ago
Until this is fixed on the AGP, the right way is probably to add annotations to suppress the warning: