Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove conditional code for handling very old AGP versions #162053

Merged
merged 3 commits into from
Mar 13, 2025

Conversation

bartekpacia
Copy link
Member

@bartekpacia bartekpacia commented Jan 23, 2025

I think code paths for AGP version <7 aren't needed anymore.

I can also imagine it will be hard to do such dynamic stuff in Kotlin, so it's better to get rid of it.

Also, I added some explicit types, this reduces the amount of grey/unresolved identifiers in IntelliJ by quite a lot, making it easier to understand code (again, this should help in conversion to Kotlin later on).

Pre-launch Checklist

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. labels Jan 23, 2025
@bartekpacia bartekpacia force-pushed the bartekpacia/chore/remove_old_agp_hacks branch 2 times, most recently from e38b007 to 60edbfd Compare January 23, 2025 17:51
@bartekpacia bartekpacia force-pushed the bartekpacia/chore/remove_old_agp_hacks branch 2 times, most recently from 81bc9fb to 8ecd473 Compare January 26, 2025 15:17
@bartekpacia bartekpacia force-pushed the bartekpacia/chore/remove_old_agp_hacks branch from bde6399 to 28502a5 Compare February 5, 2025 15:23
@bartekpacia bartekpacia requested a review from jesswrd February 5, 2025 15:23
@@ -468,7 +475,8 @@ class FlutterPlugin implements Plugin<Project> {
//
// The output file is parsed and used by devtool.
private static void addTasksForOutputsAppLinkSettings(Project project) {
project.android.applicationVariants.all { variant ->
BaseAppModuleExtension android = project.extensions.findByType(BaseAppModuleExtension.class)
Copy link
Member

Choose a reason for hiding this comment

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

Is it important that this be a BaseAppModuleExtension? I believe ApplicationExtension is a supertype that isn't marked internal. I'd like to avoid importing internal classes if possible here.

Copy link
Member

Choose a reason for hiding this comment

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

By marked internal I mean has internal in it's package name. For some reason AGP has a lot of classes with internal in their package name that are still public, but I assume that could change any release without notice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, if an internal import is required then lets add a comment explaining why and moving forward.

Copy link
Member Author

Choose a reason for hiding this comment

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

got it, will update it soon

Copy link
Member Author

Choose a reason for hiding this comment

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

done:)

@@ -1415,14 +1416,15 @@ class FlutterPlugin implements Plugin<Project> {
return copyFlutterAssetsTask
} // end def addFlutterDeps
if (isFlutterAppProject()) {
project.android.applicationVariants.all { variant ->
Task assembleTask = getAssembleTask(variant)
BaseAppModuleExtension android = project.extensions.findByType(BaseAppModuleExtension.class)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here

Copy link
Member

@gmackall gmackall left a comment

Choose a reason for hiding this comment

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

Mostly LGTM but I'd like to avoid importing internal classes, see comment

Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

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

Please dont merge unless @gmackall approves.

@@ -468,7 +475,8 @@ class FlutterPlugin implements Plugin<Project> {
//
// The output file is parsed and used by devtool.
private static void addTasksForOutputsAppLinkSettings(Project project) {
project.android.applicationVariants.all { variant ->
BaseAppModuleExtension android = project.extensions.findByType(BaseAppModuleExtension.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, if an internal import is required then lets add a comment explaining why and moving forward.

@jesswrd
Copy link
Contributor

jesswrd commented Mar 11, 2025

from android triage: @bartekpacia Is this still on your radar? If not, no worries. We are happy to close it.

@bartekpacia
Copy link
Member Author

Yup thanks for reminding. I'll get it finished very soon

@bartekpacia bartekpacia force-pushed the bartekpacia/chore/remove_old_agp_hacks branch from 28502a5 to 25c34f2 Compare March 12, 2025 21:10
@@ -1426,6 +1440,7 @@ class FlutterPlugin implements Plugin<Project> {
assert(appProject != null) : "Project :${hostAppProjectName} doesn't exist. To customize the host app project name, set `flutter.hostAppProjectName=<project-name>` in gradle.properties."
// Wait for the host app project configuration.
appProject.afterEvaluate {
// AndroidComponentsExtension android = appProject.extensions.findByType(AndroidComponentsExtension.class)
Copy link
Member

Choose a reason for hiding this comment

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

Probably meant to delete this?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yes, sorry

@@ -467,7 +474,8 @@ class FlutterPlugin implements Plugin<Project> {
//
// The output file is parsed and used by devtool.
private static void addTasksForOutputsAppLinkSettings(Project project) {
project.android.applicationVariants.all { variant ->
AbstractAppExtension android = (AbstractAppExtension) project.extensions.findByName("android")
Copy link
Member

Choose a reason for hiding this comment

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

Does this not work with the findByType method? I prefer that to casting, if it does work. No worries if not.

Copy link
Member Author

@bartekpacia bartekpacia Mar 12, 2025

Choose a reason for hiding this comment

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

Apparently findByType needs an specific type, not some supertype. When I passed AbstractAppExtension to findByType it crashed :(

Copy link
Member

Choose a reason for hiding this comment

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

Hmm would it maybe work with ApplicationExtension instead of AbstractApplicationExtension? I believe we are already doing this here

project.extensions.findByType(ApplicationExtension::class.java) ?: return

Copy link
Member Author

@bartekpacia bartekpacia Mar 12, 2025

Choose a reason for hiding this comment

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

unfortunately then applicationVariants isn't recognized, and this is why I put an explicit type here in the first place (to aid in migration to statically typed Kotlin later on)

Screenshot 2025-03-12 at 23 44 43

Copy link
Member

Choose a reason for hiding this comment

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

Hmm okay, LGTM then

@bartekpacia bartekpacia force-pushed the bartekpacia/chore/remove_old_agp_hacks branch from 25c34f2 to f741f50 Compare March 12, 2025 22:23
@bartekpacia bartekpacia added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 12, 2025
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #162053 at sha f741f50

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Mar 12, 2025
@bartekpacia
Copy link
Member Author

bartekpacia commented Mar 13, 2025

@gmackall something's up with goldens?

@reidbaker
Copy link
Contributor

@gmackall something's up with goldens?

updating branch I dont think this pr would update goldens

@auto-submit auto-submit bot added this pull request to the merge queue Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants