Declare AGP plugin in projects build.gradle#5490
Conversation
|
You can test the changes on this Pull Request by downloading the APK here. |
oguzkocer
left a comment
There was a problem hiding this comment.
@wzieba I think your deduction is correct. To elaborate on it a bit more, here navigation-safe-args-gradle-plugin declares AGP 4.2.0 as a direct dependency. It's hard to say for sure without investigating the code, but I think that might be a mistake and it should instead be declared as compileOnly. AGP is not actually applied from the plugin as far as I can tell and instead an error is thrown if it's not already applied, so making it a direct dependency seems counterproductive.
Gradle's dependency resolution is also a bit unintuitive in my opinion, because I'd expect a plugin dependency to be resolved to the version defined in settings.gradle especially if it's higher. I wouldn't be surprised if the current behavior is not intended, but 🤷
Good catch, thanks for the link to source! |
Closes: #5489
Description
Included builds stopped working because of incompatible AGP versions. Error message claims that
FluxCis using4.2.2whenWoo-4.2.0.This sounds strange as in Woo we specifically declare version
4.2.0insettings.gradle.After research, I've found that AGP bundled with

androidx.navigation.safeargs.kotlintakes precedence and is used to build app:Link to scan: https://scans.gradle.com/s/si4e3edu26ghu
Link to
safeargssource: https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-main/navigation/navigation-safe-args-gradle-plugin/build.gradle?source=post_page---------------------------%2F&autodive=0%2F%2F#28I suspect, this is because we do declare (not apply)
androidx.navigation.safeargs.kotlinin projectsbuild.gradleas we discussed in previous related PR (#5414 (comment)).My fix proposal is about declaring one of AGP plugins in projects
build.gradleso our version, applied fromsettings.gradleis resolved, instead of version taken fromsafeargs.I think there are no downsides of this solution besides clanky syntax. I'm also quite surprised by this behaviour of Gradle as it kinda hides this resolution and shadows the real behaviour.
I'd love to spend some time in understanding this but for now, I think this fix is sufficient.
Testing instructions
Please uncomment any build from
local-builds.gradleand see if app compiles.RELEASE-NOTES.txtif necessary.