|
| 1 | +# Flutter Tools for Android |
| 2 | + |
| 3 | +This section of the Flutter repository contains the command line developer tools |
| 4 | +for building Flutter applications on Android. What follows are some notes about |
| 5 | +updating this part of the tool. |
| 6 | + |
| 7 | +## Updating Android dependencies |
| 8 | +The Android dependencies that Flutter uses to run on Android |
| 9 | +include the Android NDK and SDK versions, Gradle, the Kotlin Gradle Plugin, |
| 10 | +and the Android Gradle Plugin (AGP). The template versions of these |
| 11 | +dependencies can be found in [gradle_utils.dart](gradle_utils.dart). |
| 12 | + |
| 13 | +Follow the guides below when*... |
| 14 | + |
| 15 | +### Updating the template version of... |
| 16 | + |
| 17 | +#### The Android SDK & NDK |
| 18 | +All of the Android SDK/NDK versions noted in `gradle_utils.dart` |
| 19 | +(`compileSdkVersion`, `minSdkVersion`, `targetSdkVersion`, `ndkVersion`) |
| 20 | +versions should match the values in Flutter Gradle Plugin (`FlutterExtension`), |
| 21 | +so updating any of these versions also requires an update in |
| 22 | +[flutter.groovy](../../../gradle/src/main/groovy/flutter.groovy). |
| 23 | + |
| 24 | +When updating the Android `compileSdkVersion`, `minSdkVersion`, or |
| 25 | +`targetSdkVersion`, make sure that: |
| 26 | +- Framework integration & benchmark tests are running with at least that SDK |
| 27 | +version. |
| 28 | +- Flutter tools tests that perform String checks with the current template |
| 29 | +SDK verisons are updated (you should see these fail if you do not fix them |
| 30 | +preemptively). |
| 31 | + |
| 32 | +#### Gradle |
| 33 | +When updating the Gradle version used in project templates |
| 34 | +(`templateDefaultGradleVersion`), make sure that: |
| 35 | +- Framework integration & benchmark tests are running with at least this Gradle |
| 36 | +version. |
| 37 | +- Flutter tools tests that perform String checks with the current template |
| 38 | +Gradle version are updated (you should see these fail if you do not fix them |
| 39 | +preemptively). |
| 40 | + |
| 41 | +#### The Kotlin Gradle Plugin |
| 42 | +When updating the Kotlin Gradle Plugin (KGP) version used in project templates |
| 43 | +(`templateKotlinGradlePluginVersion`), make sure that the framework integration |
| 44 | +& benchmark tests are running with at least this KGP version. |
| 45 | + |
| 46 | +For information aboout the latest version, check https://kotlinlang.org/docs/releases.html#release-details. |
| 47 | + |
| 48 | +#### The Android Gradle Plugin (AGP) |
| 49 | +When updating the Android Gradle Plugin (AGP) versions used in project templates |
| 50 | +(`templateAndroidGradlePluginVersion`, `templateAndroidGradlePluginVersionForModule`), |
| 51 | +make sure that: |
| 52 | +- Framework integration & benchmark tests are running with at least this AGP |
| 53 | +version. |
| 54 | +- Flutter tools tests that perform String checks with the current template |
| 55 | +AGP verisons are updated (you should see these fail if you do not fix them |
| 56 | +preemptively). |
| 57 | + |
| 58 | +### A new version becomes available for... |
| 59 | + |
| 60 | +#### Gradle |
| 61 | +When new versions of Gradle become available, make sure to: |
| 62 | +- Check if the maximum version of Gradle that we support |
| 63 | +(`maxKnownAndSupportedGradleVersion`) can be updated, and if so, take the |
| 64 | +necessary steps to ensure we are testing this version in CI. |
| 65 | +- Check that the Java version that is one higher than we currently support |
| 66 | +(`oneMajorVersionHigherJavaVersion`) based on current maximum supported |
| 67 | +Gradle version is up-to-date. |
| 68 | +- Update the `_javaGradleCompatList` that contains the Java/Gradle |
| 69 | +compatibility information known to the tool. |
| 70 | +- Update the test cases in [gradle_utils_test.dart](../../..test/general.shard/android/gradle_utils_test.dart) that test compatibility between Java and Gradle versions |
| 71 | +(relevant tests should fail if you do not fix them preemptively, but should also |
| 72 | +be marked inline). |
| 73 | +- Update the test cases in [create_test.dart](../../../test/commands.shard/permeable/create_test.dart) that test for a warning for Java/Gradle incompatibilities as needed |
| 74 | +(relevant tests should fail if you do not fix them preemptively). |
| 75 | + |
| 76 | +For more information about the latest version, check https://gradle.org/releases/. |
| 77 | + |
| 78 | +#### The Android Gradle Plugin (AGP) |
| 79 | +When new versions of the Android Gradle Plugin become available, make sure to: |
| 80 | +- Update the maximum version of AGP that we know of (`maxKnownAgpVersion`). |
| 81 | +- Check if the maximum version of AGP that we support |
| 82 | +(`maxKnownAndSupportedAgpVersion`) can be updated, and if so, take the necessary |
| 83 | +steps to ensure that we are testing this version in CI. |
| 84 | +- Update the `_javaAgpCompatList` that contains the Java/AGP compatibility |
| 85 | +information known to the tool. |
| 86 | +- Update the test cases in [gradle_utils_test.dart](../../..test/general.shard/android/gradle_utils_test.dart) that test compatibility between Java and AGP versions |
| 87 | +(relevant tests should fail if you do not fix them preemptively, but should also |
| 88 | +be marked inline). |
| 89 | +- Update the test cases in [create_test.dart](../../../test/commands.shard/permeable/create_test.dart) that test for a warning for Java/AGP incompatibilities as needed |
| 90 | +(relevant tests should fail if you do not fix them preemptively). |
| 91 | + |
| 92 | +For information about the latest version, check https://developer.android.com/studio/releases/gradle-plugin#updating-gradle. |
| 93 | + |
| 94 | +\* There is an ongoing effort to reduce these steps; see https://github.com/flutter/flutter/issues/134780. |
0 commit comments