Skip to content

Conversation

@brunotacca
Copy link
Contributor

@brunotacca brunotacca commented Dec 22, 2021

This PR changes the build.gradle files to read the flutter.minSdkVersion and flutter.targetSdkVersion from the generated local.properties, and if not found, keep the default one (which is set at flutter.gradle)

It changes all build.gradle files from examples/* and the integration_test/example.
It doesn't change build.gradle files from dev projects at dev/* but they can be changed too upon further request.
It changes both java and kotlin build.gradle templates.
It changes the default app test to expect the new strings on build.gradle.
It doesn't apply the same concept to flutter.compileSdkVersion, so having it on local.properties doesn't change the value set at flutter.gradle, this can also be added upon further request.

This PR also changes flutter.gradle to detect and warn the developer with a logger.quiet message about mismatches with plugins API level. If a mismatch is found, it also checks if the variables flutter.minSdkVersion and flutter.targetSdkVersion were set at local.properties

It also changes the gradle_errors.dart to update the box message about how to fix the API level error, while adding a reference to the docs. The test was also updated.

Images:

[Before] New project with a dependency requiring higher sdk version.

image

[After] New project with a dependency requiring higher sdk version.

image

[After] New project with the variables INcorrectly set at local.properties.

image

[After] New project with the variables correctly set at local.properties.

image

It closes #95533
Partially solves #95485 (Android part)
Could be a solution to #95514

Extra - Not related: at 0440790 I fixed the command required to export the FLUTTER_ROOT variable in order to run tests.

@flutter-dashboard flutter-dashboard bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation f: integration_test The flutter/packages/integration_test plugin c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Dec 22, 2021
@meysammahfouzi
Copy link

How are the values of flutter.minSdkVersion and flutter.targetSdkVersion initialized at the moment?

@brunotacca
Copy link
Contributor Author

brunotacca commented Dec 26, 2021 via email

@christopherfujino
Copy link
Contributor

@brunotacca this has merge conflicts with upstream, can you rebase or merge in master to resolve before this is reviewed?

@christopherfujino christopherfujino added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 27, 2022
@brunotacca
Copy link
Contributor Author

@brunotacca this has merge conflicts with upstream, can you rebase or merge in master to resolve before this is reviewed?

Thank you for notifying me.
There was a conflict with 0e2f51d on packages/flutter_tools/test/commands.shard/permeable/create_test.dart since it changed the same test to verify the build.gradle contents, the ndkVersion flutter.ndkVersion was added.

@christopherfujino
Copy link
Contributor

@camsim99 can you (or someone else on the android team) take a look at this PR?

@camsim99 camsim99 self-requested a review February 11, 2022 18:20
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it something to warn about if the developer doesn't specify it in local.properties? I suppose adding this warning could help with Issue #95514, though. Is that your reasoning?

Same comment for flutterTargetSdkVersion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly that, it could prevent similar issues in the future. Although, since now there is mention of the local.properties on the flutter website docs, I don't know if it's that necessary anymore.

Copy link
Contributor

@camsim99 camsim99 Feb 11, 2022

Choose a reason for hiding this comment

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

Oh gotcha! Could we possibly move the warning to flutter.gradle and only show it when not defining it will be a problem, i.e. when the minSdkVersion of a dependency is higher than that of the flutter project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Certainly, I gonna need a little bit of time to understand how flutter.gradle works but I am on it. Let me get this straight, ideally, what would be the conditions to trigger the custom warning about local.properties?

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like if the minSdkVersion of a dependency is greater than that of the mindSdkVersion defined in flutter.gradle, we show the warning so that the person knows how to fix the error that will appear. You can even add a link to your update on the website to the warning for context!

It should be similar to the way we compare the compileSdkVersions of the project and its plugin dependencies right now (see here), but let me know if I can help!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much, that should be more than enough for me to get started. I will let you know if I get stuck, thanks!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@camsim99 Updated the PR description, images. I changed flutter.gradle and also gradle_errors.dart.

Thank you for reviewing.

@brunotacca brunotacca changed the title reads min/target sdk versions from localproperties [WIP] reads min/target sdk versions from localproperties Feb 11, 2022
@brunotacca brunotacca marked this pull request as draft February 12, 2022 01:57
@brunotacca brunotacca marked this pull request as ready for review February 12, 2022 04:10
@brunotacca brunotacca requested a review from camsim99 February 12, 2022 04:11
@brunotacca brunotacca changed the title [WIP] reads min/target sdk versions from localproperties reads min/target sdk versions from localproperties Feb 12, 2022
Copy link
Contributor

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

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

LGTM! Just need to get the tests passing :)

@christopherfujino
Copy link
Contributor

To get customer_testing to pass, you will need to rebase (not merge) upstream master.

* Refactor TextSelectionOverlay

* fix test

* remove print

* fix more tests

* update

* added tests

* fix comments

* fmt

* fix test

* addressing comment

* remove dispose

* remove new line
@brunotacca
Copy link
Contributor Author

@christopherfujino It seems that I did something wrong trying to rebase... Should I close this and make another PR?

@brunotacca brunotacca marked this pull request as draft February 14, 2022 22:54
@christopherfujino
Copy link
Contributor

@christopherfujino It seems that I did something wrong trying to rebase... Should I close this and make another PR?

That works if you are not able to resolve the bad rebase.

@brunotacca
Copy link
Contributor Author

@christopherfujino #98450 I think I did it correctly this time, sorry for the inconvenience.

@brunotacca brunotacca closed this Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos dependency: android Android team may need to help us f: integration_test The flutter/packages/integration_test plugin tool Affects the "flutter" command-line tool. See also t: labels. waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] build.gradle defaultConfig with local.properties not working properly.