Fixes https://github.com/flutter/flutter/issues/161443
* adds a new gradle task like `javaVersion` named `kgpVersion` that
prints the version of kgp.
* adds gradle_utils.dart method for getting kgp version
* * kgp method is moved to utilities and we attempt to use a plugin
method before reflection.
* adds methods or evaluating KGP + gradle and KGP + AGP compatibility.
* * It turns out that we have been using incompatible versions that
happen to work with the subset of kotlin we are using.
* Uses new kgp methods in flutter analyze --suggestions as part of the
existing agp/java/gradle compatibility matrix.
* adds new tests for all new functionality
* Adds comments to sections of the code I found could use them.
* Modifies flutter gallery to use a compatible version of kotlin and
update its lockfiles.
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [X] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.
**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.
---------
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
Fixes https://github.com/flutter/flutter/issues/112833
Most of the actual changes here are in [packages/flutter_tools/lib/src/version.dart](https://github.com/flutter/flutter/pull/124558/files#diff-092e00109d9e1589fbc7c6de750e29a6ae512b2dd44e85d60028953561201605), while the rest is largely just addressing changes to the constructor of `FlutterVersion` which now has different dependencies.
This change makes `FlutterVersion` an interface with two concrete implementations:
1. `_FlutterVersionGit` which is mostly the previous implementation, and
2. `_FlutterVersionFromFile` which will read a new `.version.json` file from the root of the repo
The [`FlutterVersion` constructor](https://github.com/flutter/flutter/pull/124558/files#diff-092e00109d9e1589fbc7c6de750e29a6ae512b2dd44e85d60028953561201605R70) is now a factory that first checks if `.version.json` exists, and if so returns an instance of `_FlutterVersionFromGit` else it returns the fallback `_FlutterVersionGit` which will end up writing `.version.json` so that we don't need to re-calculate the version on the next invocation.
`.version.json` will be deleted in the bash/batch entrypoints any time we need to rebuild he tool (this will usually be because the user did `flutter upgrade` or `flutter channel`, or manually changed the commit with git).
https://github.com/flutter/flutter/issues/123917
Doc covering a broad set of issues related to android studio updating.
https://docs.google.com/document/d/1hTXkjbUrBnXgu8NQsth1c3aEqo77rWoEj8CcsQ39wwQ/edit?pli=1#
Specifically this pr:
- Adds new functions to find a projects AGP, Gradle and java versions,
and tests.
- Adds new functions that take versions and parse if the versions are
compatible with each other, and tests.
- Adds validator for `flutter analyze --suggestions` that evaluates the
java/gradle/agp versions and checks if they are compatible, and
integration test.
- Updates the version of gradle used by
dev/integration_tests/flutter_gallery/ to the minimum supported by java
18 so that the integration tests pass (It is unknown why the java
version is 18.9 instead of 11)
- Moves `isWithinVersionRange` to version.dart, and tests.
- Adds FakeAndroidStudio to fakes to be used in multiple tests but does
not remove existing copies.
Metrics will be included as part of the definition of done for this bug
but not as part of this cl. It is already too big.
Known work still left in this pr:
* Understand why analyze integration tests are failing.
Example output if Java and gradle are not compatible:
```
┌───────────────────────────────────────────────────────────────────┐
│ General Info │
│ [✓] App Name: espresso_example │
│ [✓] Supported Platforms: android │
│ [✓] Is Flutter Package: yes │
│ [✓] Uses Material Design: yes │
│ [✓] Is Plugin: no │
│ [✗] Java/Gradle/Android Gradle Plugin: │
│ │
│ Incompatible Java/Gradle versions. │
│ │
│ Java Version: 17.0.6, Gradle Version: 7.0.2 │
│ │
│ See the link below for more information. │
│ https://docs.gradle.org/current/userguide/compatibility.html#java │
│ │
└───────────────────────────────────────────────────────────────────┘
```
Example output if Gradle and AGP are not compatible
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ General Info │
│ [✓] App Name: espresso_example │
│ [✓] Supported Platforms: android │
│ [✓] Is Flutter Package: yes │
│ [✓] Uses Material Design: yes │
│ [✓] Is Plugin: no │
│ [✗] Java/Gradle/Android Gradle Plugin: Incompatible Gradle/AGP versions. │
│ │
│ Gradle Version: 7.0.2, AGP Version: 7.4.2 │
│ │
│ Update gradle to at least "7.5". │
│ See the link below for more information: │
│ https://developer.android.com/studio/releases/gradle-plugin#updating-gradle │
│ │
│ Incompatible Java/Gradle versions. │
│ │
│ Java Version: 17.0.6, Gradle Version: 7.0.2 │
│ │
│ See the link below for more information: │
│ https://docs.gradle.org/current/userguide/compatibility.html#java │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
```
Example output if Java/Gradle/Agp are not compatible.
```
┌─────────────────────────────────────────────────────────────────────────────┐
│ General Info │
│ [✓] App Name: espresso_example │
│ [✓] Supported Platforms: android │
│ [✓] Is Flutter Package: yes │
│ [✓] Uses Material Design: yes │
│ [✓] Is Plugin: no │
│ [✗] Java/Gradle/Android Gradle Plugin: Incompatible Gradle/AGP versions. │
│ │
│ Gradle Version: 7.0.2, AGP Version: 7.4.2 │
│ │
│ Update gradle to at least "7.5". │
│ See the link below for more information: │
│ https://developer.android.com/studio/releases/gradle-plugin#updating-gradle │
│ │
│ Incompatible Java/Gradle versions. │
│ │
│ Java Version: 17.0.6, Gradle Version: 7.0.2 │
│ │
│ See the link below for more information: │
│ https://docs.gradle.org/current/userguide/compatibility.html#java │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
```
Commit messages
- Add function to gradle_utils.dart that gets the gradle version from
wrapper or system and add a test for each situation
- Add method to get agp version, add method to validate agp against
gradle version, update documentation, add tests for agp validation.
- Update dart doc for validateGradleAndAgp to describe where the info
came from and corner case behavior, create function to validate java and
gradle and hardcode return to false
- Fill out and test java gradle compatibility function in gradle_utils
- Hook up java gradle evaluateion to hasValidJavaGradleAgpVersions with
hardcoded java version
- Add java --version output parsing and tests
- Add getJavaBinary test
- Update comment in android_sdk for mac behavior with java_home -v
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] All existing and new tests are passing.
Fuchsia will soon remove all support for Component Framework version 1
components (recognized by component manifests ending in `.cmx`).
Notably, some of the `flutter` tool commands for Fuchsia devices--
notably, but not limited to, those related to CFv1--are outdated, and
either do not work today or soon won't work.
This PR removes the outdated components and commands, replacing some
with the newer version, or simply removing the non-working features,
in some cases.