flutter/packages/flutter_tools/lib/src/android
Nate c53a18f4e4
Implementing null-aware operators throughout the repository (#143804)
This pull request fixes #143803 by taking advantage of Dart's null-aware operators.

And unlike `switch` expressions ([9 PRs](https://github.com/flutter/flutter/pull/143634) and counting), the Flutter codebase is already fantastic when it comes to null-aware coding. After refactoring the entire repo, all the changes involving `?.` and `??` can fit into a single pull request.
2024-02-23 19:02:22 +00:00
..
migrations Update Android minSdkVersion to 21 (#142267) 2024-01-29 09:49:09 -08:00
adb.dart Migrate flutter_tool tool helper files to null safety (#78845) 2021-03-23 10:02:59 -07:00
android_builder.dart Improves output file path logic in Android analyze (#136981) 2023-11-16 22:59:02 +00:00
android_console.dart Migrate android_console to null safety (#78923) 2021-03-24 15:18:00 -07:00
android_device_discovery.dart Stop recommending android sdk root (#136296) 2023-10-11 21:04:59 +00:00
android_device.dart Update Android minSdkVersion to 21 (#142267) 2024-01-29 09:49:09 -08:00
android_emulator.dart Enable private field promotion for flutter_tools (#134474) 2023-09-12 20:20:04 +00:00
android_sdk.dart Implementing null-aware operators throughout the repository (#143804) 2024-02-23 19:02:22 +00:00
android_studio_validator.dart [tool] In flutter doctor -v, warn when Android Studio version could not be detected. (#126395) 2023-06-01 14:51:30 +00:00
android_studio.dart handle exceptions raised while searching for configured android studio (#133180) 2023-08-24 17:36:19 +00:00
android_workflow.dart Remove duplicate global declaration of UserMessages (#142281) 2024-01-26 21:41:16 +00:00
android.dart Migrate flutter_tool tool helper files to null safety (#78845) 2021-03-23 10:02:59 -07:00
application_package.dart flutter-tool: enum cleanup (#124760) 2023-04-14 01:55:05 +00:00
build_validation.dart flutter-tool: enum cleanup (#124760) 2023-04-14 01:55:05 +00:00
deferred_components_gen_snapshot_validator.dart Remove unnecessary null checks in flutter_tool (#118857) 2023-01-23 21:43:08 +00:00
deferred_components_prebuild_validator.dart Add support for Gradle Kotlin DSL (#140744) 2024-01-12 02:20:06 +00:00
deferred_components_validator.dart Remove unnecessary null checks in flutter_tool (#118857) 2023-01-23 21:43:08 +00:00
gradle_errors.dart [flutter_tool] Retry a gradle build on connection timeout (#143084) 2024-02-08 12:39:00 -08:00
gradle_utils.dart Update AGP version validation code to support KGP and kotlin build files. (#142357) 2024-02-05 21:47:39 +00:00
gradle.dart [Re-re-land] Enforce a policy on supported Gradle, Java, AGP, and KGP versions (#143341) 2024-02-13 15:44:17 +00:00
java.dart Implementing null-aware operators throughout the repository (#143804) 2024-02-23 19:02:22 +00:00
README.md [Re-re-land] Enforce a policy on supported Gradle, Java, AGP, and KGP versions (#143341) 2024-02-13 15:44:17 +00:00

Flutter Tools for Android

This section of the Flutter repository contains the command line developer tools for building Flutter applications on Android. What follows are some notes about updating this part of the tool.

Updating Android dependencies

The Android dependencies that Flutter uses to run on Android include the Android NDK and SDK versions, Gradle, the Kotlin Gradle Plugin, and the Android Gradle Plugin (AGP). The template versions of these dependencies can be found in gradle_utils.dart.

Follow the guides below when*...

Updating the template version of...

The Android SDK & NDK

All of the Android SDK/NDK versions noted in gradle_utils.dart (compileSdkVersion, minSdkVersion, targetSdkVersion, ndkVersion) versions should match the values in Flutter Gradle Plugin (FlutterExtension), so updating any of these versions also requires an update in flutter.groovy.

When updating the Android compileSdkVersion, minSdkVersion, or targetSdkVersion, make sure that:

  • Framework integration & benchmark tests are running with at least that SDK version.
  • Flutter tools tests that perform String checks with the current template SDK versions are updated (you should see these fail if you do not fix them preemptively).

Also, make sure to also update to the same version in the following places:

  • The version in the buildscript block in packages/flutter_tools/gradle/src/main/groovy/flutter.groovy.
  • The version in the buildscript block in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts.
  • The version in the dependencies block in packages/flutter_tools/gradle/build.gradle.kts.

Gradle

When updating the Gradle version used in project templates (templateDefaultGradleVersion), make sure that:

  • Framework integration & benchmark tests are running with at least this Gradle version.
  • Flutter tools tests that perform String checks with the current template Gradle version are updated (you should see these fail if you do not fix them preemptively).

The Kotlin Gradle Plugin

When updating the Kotlin Gradle Plugin (KGP) version used in project templates (templateKotlinGradlePluginVersion), make sure that the framework integration & benchmark tests are running with at least this KGP version.

For information about the latest version, check https://kotlinlang.org/docs/releases.html#release-details.

The Android Gradle Plugin (AGP)

When updating the Android Gradle Plugin (AGP) versions used in project templates (templateAndroidGradlePluginVersion, templateAndroidGradlePluginVersionForModule), make sure that:

  • Framework integration & benchmark tests are running with at least this AGP version.
  • Flutter tools tests that perform String checks with the current template AGP versions are updated (you should see these fail if you do not fix them preemptively).

A new version becomes available for...

Gradle

When new versions of Gradle become available, make sure to:

  • Check if the maximum version of Gradle that we support (maxKnownAndSupportedGradleVersion) can be updated, and if so, take the necessary steps to ensure we are testing this version in CI.
  • Check that the Java version that is one higher than we currently support (oneMajorVersionHigherJavaVersion) based on current maximum supported Gradle version is up-to-date.
  • Update the _javaGradleCompatList that contains the Java/Gradle compatibility information known to the tool.
  • Update the test cases in gradle_utils_test.dart that test compatibility between Java and Gradle versions (relevant tests should fail if you do not fix them preemptively, but should also be marked inline).
  • Update the test cases in create_test.dart that test for a warning for Java/Gradle incompatibilities as needed (relevant tests should fail if you do not fix them preemptively).

For more information about the latest version, check https://gradle.org/releases/.

The Android Gradle Plugin (AGP)

When new versions of the Android Gradle Plugin become available, make sure to:

  • Update the maximum version of AGP that we know of (maxKnownAgpVersion).
  • Check if the maximum version of AGP that we support (maxKnownAndSupportedAgpVersion) can be updated, and if so, take the necessary steps to ensure that we are testing this version in CI.
  • Update the _javaAgpCompatList that contains the Java/AGP compatibility information known to the tool.
  • Update the test cases in gradle_utils_test.dart that test compatibility between Java and AGP versions (relevant tests should fail if you do not fix them preemptively, but should also be marked inline).
  • Update the test cases in create_test.dart that test for a warning for Java/AGP incompatibilities as needed (relevant tests should fail if you do not fix them preemptively).

For information about the latest version, check https://developer.android.com/studio/releases/gradle-plugin#updating-gradle.

* There is an ongoing effort to reduce these steps; see https://github.com/flutter/flutter/issues/134780.