Android templates: update default Kotlin from 1.8.22 to 2.1.0, update default Gradle from 8.9 to 8.12 (#160974)

This commit is contained in:
Bartek Pacia 2025-01-23 20:39:32 +01:00 committed by GitHub
parent 1daa75598b
commit 558b21abf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 31 additions and 17 deletions

View File

@ -15,8 +15,8 @@ import 'package:flutter_devicelab/framework/framework.dart';
// https://developer.android.com/build/releases/past-releases/agp-8-4-0-release-notes. // https://developer.android.com/build/releases/past-releases/agp-8-4-0-release-notes.
// - Kotlin: No methodology as of yet. // - Kotlin: No methodology as of yet.
// (*) - support range defined in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts. // (*) - support range defined in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts.
// Note that compileSdk 35 requires AGP 8.1.0+, so override to compileSdk 34 for AGP 8.0.
List<VersionTuple> versionTuples = <VersionTuple>[ List<VersionTuple> versionTuples = <VersionTuple>[
// compileSdk 35 requires AGP 8.1.0+, so override to compileSdk 34 for AGP 8.0.
VersionTuple( VersionTuple(
agpVersion: '8.0.0', agpVersion: '8.0.0',
gradleVersion: '8.0', gradleVersion: '8.0',
@ -30,6 +30,8 @@ List<VersionTuple> versionTuples = <VersionTuple>[
VersionTuple(agpVersion: '8.5.0', gradleVersion: '8.7', kotlinVersion: '1.8.22'), VersionTuple(agpVersion: '8.5.0', gradleVersion: '8.7', kotlinVersion: '1.8.22'),
VersionTuple(agpVersion: '8.6.0', gradleVersion: '8.7', kotlinVersion: '1.8.22'), VersionTuple(agpVersion: '8.6.0', gradleVersion: '8.7', kotlinVersion: '1.8.22'),
VersionTuple(agpVersion: '8.7.0', gradleVersion: '8.9', kotlinVersion: '1.8.22'), VersionTuple(agpVersion: '8.7.0', gradleVersion: '8.9', kotlinVersion: '1.8.22'),
VersionTuple(agpVersion: '8.7.0', gradleVersion: '8.9', kotlinVersion: '2.1.0'),
VersionTuple(agpVersion: '8.7.0', gradleVersion: '8.12', kotlinVersion: '2.1.0'),
]; ];
Future<void> main() async { Future<void> main() async {

View File

@ -7,7 +7,7 @@
// See dev/tools/bin/generate_gradle_lockfiles.dart. // See dev/tools/bin/generate_gradle_lockfiles.dart.
buildscript { buildscript {
ext.kotlin_version = '1.8.22' ext.kotlin_version = '2.1.0'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()

View File

@ -22,14 +22,21 @@ import 'android_sdk.dart';
// These are the versions used in the project templates. // These are the versions used in the project templates.
// //
// In general, Flutter aims to default to the latest version. // In general, Flutter aims to default to the latest stable version.
// However, this currently requires to migrate existing integration tests to the latest supported values. // However, this currently requires to migrate existing integration tests to the
// latest supported values.
// //
// Please see the README before changing any of these values. // Please see the README before changing any of these values.
const String templateDefaultGradleVersion = '8.10.2';
const String templateAndroidGradlePluginVersion = '8.7.0'; // See https://gradle.org/releases
const String templateAndroidGradlePluginVersionForModule = '8.7.0'; const String templateDefaultGradleVersion = '8.12';
const String templateKotlinGradlePluginVersion = '1.8.22';
// See https://mvnrepository.com/artifact/com.android.tools.build/gradle
const String templateAndroidGradlePluginVersion = '8.7.3';
const String templateAndroidGradlePluginVersionForModule = '8.7.3';
// See https://kotlinlang.org/docs/releases.html#release-details
const String templateKotlinGradlePluginVersion = '2.1.0';
// The Flutter Gradle Plugin is only applied to app projects, and modules that // The Flutter Gradle Plugin is only applied to app projects, and modules that
// are built from source using (`include_flutter.groovy`). The remaining // are built from source using (`include_flutter.groovy`). The remaining
@ -53,17 +60,17 @@ const String oneMajorVersionHigherJavaVersion = '24';
// //
// Supported here means supported by the tooling for // Supported here means supported by the tooling for
// flutter analyze --suggestions and does not imply broader flutter support. // flutter analyze --suggestions and does not imply broader flutter support.
const String maxKnownAndSupportedGradleVersion = '8.10.2'; const String maxKnownAndSupportedGradleVersion = '8.12';
// Update this when new versions of AGP come out. // Update this when new versions of AGP come out.
// //
// Supported here means tooling is aware of this version's Java <-> AGP // Supported here means tooling is aware of this version's Java <-> AGP
// compatibility. // compatibility.
@visibleForTesting @visibleForTesting
const String maxKnownAndSupportedAgpVersion = '8.7.1'; const String maxKnownAndSupportedAgpVersion = '8.7.3';
// Update this when new versions of AGP come out. // Update this when new versions of AGP come out.
const String maxKnownAgpVersion = '8.7.1'; const String maxKnownAgpVersion = '8.7.3';
// Oldest documented version of AGP that has a listed minimum // Oldest documented version of AGP that has a listed minimum
// compatible Java version. // compatible Java version.
@ -481,7 +488,7 @@ bool validateGradleAndAgp(Logger logger, {required String? gradleV, required Str
return isWithinVersionRange(gradleV, min: '4.10.1', max: maxKnownAndSupportedGradleVersion); return isWithinVersionRange(gradleV, min: '4.10.1', max: maxKnownAndSupportedGradleVersion);
} }
logger.printTrace('Unknown Gradle-Agp compatibility, $gradleV, $agpV'); logger.printTrace('Unknown Gradle-AGP compatibility, Gradle: $gradleV, AGP: $agpV');
return false; return false;
} }
@ -545,7 +552,7 @@ bool validateJavaAndGradle(Logger logger, {required String? javaV, required Stri
} }
} }
logger.printTrace('Unknown Java-Gradle compatibility $javaV, $gradleV'); logger.printTrace('Unknown Java-Gradle compatibility, Java: $javaV, Gradle: $gradleV');
return false; return false;
} }

View File

@ -22,4 +22,9 @@ class VersionRange {
@override @override
int get hashCode => Object.hash(versionMin, versionMax); int get hashCode => Object.hash(versionMin, versionMax);
@override
String toString() {
return 'VersionRange(versionMin: $versionMin, versionMax: $versionMax)';
}
} }

View File

@ -1002,7 +1002,7 @@ A problem occurred evaluating project ':app'.
"│ + classpath 'com.android.tools.build:gradle:$templateAndroidGradlePluginVersion' │\n" "│ + classpath 'com.android.tools.build:gradle:$templateAndroidGradlePluginVersion' │\n"
'│ /android/gradle/wrapper/gradle-wrapper.properties: │\n' '│ /android/gradle/wrapper/gradle-wrapper.properties: │\n'
'│ - https://services.gradle.org/distributions/gradle-<current-version>-all.zip │\n' '│ - https://services.gradle.org/distributions/gradle-<current-version>-all.zip │\n'
'│ + https://services.gradle.org/distributions/gradle-$templateDefaultGradleVersion-all.zip \n' '│ + https://services.gradle.org/distributions/gradle-$templateDefaultGradleVersion-all.zip \n'
'└──────────────────────────────────────────────────────────────────────────────────┘\n', '└──────────────────────────────────────────────────────────────────────────────────┘\n',
), ),
); );

View File

@ -1314,13 +1314,13 @@ allprojects {
); );
// Strictly too new Gradle and AGP versions. // Strictly too new Gradle and AGP versions.
expect( expect(
getJavaVersionFor(gradleV: '8.11', agpV: '8.8'), getJavaVersionFor(gradleV: '8.13', agpV: '8.9'),
equals(const VersionRange(null, null)), equals(const VersionRange(null, null)),
); );
// Strictly too new Gradle version and maximum version of AGP. // Strictly too new Gradle version and maximum version of AGP.
//*This test case will need its expected Java range updated when a new version of AGP is supported.* //*This test case will need its expected Java range updated when a new version of AGP is supported.*
expect( expect(
getJavaVersionFor(gradleV: '8.11', agpV: maxKnownAndSupportedAgpVersion), getJavaVersionFor(gradleV: '8.13', agpV: maxKnownAndSupportedAgpVersion),
equals(const VersionRange('17', null)), equals(const VersionRange('17', null)),
); );
// Strictly too new AGP version and maximum version of Gradle. // Strictly too new AGP version and maximum version of Gradle.

View File

@ -16,7 +16,7 @@ class PluginDeferredComponentsConfig extends BasicDeferredComponentsConfig {
@override @override
String get androidBuild => r''' String get androidBuild => r'''
buildscript { buildscript {
ext.kotlin_version = '1.8.22' ext.kotlin_version = '2.1.0'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()