Skip to content

Declare AGP plugin in projects build.gradle#5490

Merged
oguzkocer merged 1 commit intodevelopfrom
issue/5489_fix_included_builds
Dec 21, 2021
Merged

Declare AGP plugin in projects build.gradle#5490
oguzkocer merged 1 commit intodevelopfrom
issue/5489_fix_included_builds

Conversation

@wzieba
Copy link
Copy Markdown
Contributor

@wzieba wzieba commented Dec 21, 2021

Closes: #5489

Description

Included builds stopped working because of incompatible AGP versions. Error message claims that FluxC is using 4.2.2 when Woo - 4.2.0.

This sounds strange as in Woo we specifically declare version 4.2.0 in settings.gradle.


After research, I've found that AGP bundled with androidx.navigation.safeargs.kotlin takes precedence and is used to build app:
image

Link to scan: https://scans.gradle.com/s/si4e3edu26ghu
Link to safeargs source: 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#28

I suspect, this is because we do declare (not apply) androidx.navigation.safeargs.kotlin in projects build.gradle as we discussed in previous related PR (#5414 (comment)).

My fix proposal is about declaring one of AGP plugins in projects build.gradle so our version, applied from settings.gradle is resolved, instead of version taken from safeargs.

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.gradle and see if app compiles.

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wzieba wzieba added category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. type: bug A confirmed bug. labels Dec 21, 2021
@wzieba wzieba marked this pull request as draft December 21, 2021 09:10
@peril-woocommerce
Copy link
Copy Markdown

You can test the changes on this Pull Request by downloading the APK here.

@wzieba wzieba marked this pull request as ready for review December 21, 2021 09:30
@wzieba wzieba requested a review from oguzkocer December 21, 2021 09:30
Copy link
Copy Markdown
Contributor

@oguzkocer oguzkocer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 🤷

@oguzkocer oguzkocer merged commit 82d5a57 into develop Dec 21, 2021
@oguzkocer oguzkocer deleted the issue/5489_fix_included_builds branch December 21, 2021 21:05
@wzieba
Copy link
Copy Markdown
Contributor Author

wzieba commented Dec 22, 2021

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.

Good catch, thanks for the link to source!

@wzieba wzieba mentioned this pull request Dec 24, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Included builds stopped working after migrating to Plugin DSL

2 participants