Update template/test compileSdk, targetSdk, ndk versions (#152487)

Updates `compileSdk`, `targetSdk`, and `ndk` versions (former 2 to latest, latter to the version of the ndk we are hosting on CIPD).

Summary of changes:
- Updates mentioned template values
- `compileSdk` 35 requires AGP 8.0+, so updated to 8.1 in many places.
- This also necessitated Gradle upgrades in most places
- This also necessitated moving the `package` xml attribute to the AGP `namespace` field in a couple places (test + template).
- Some tests use the output of `flutter create` but then use intentionally lower AGP versions. [I downgraded the `compileSdk` in these tests.](fee34fd61a)
- [Stopped lockfile generation](82324a2570) script from hitting the `hello_world` example because it uses `.kts` gradle files.
- One test needed [some Gradle options we had already added to templates](6aa187b4b6).
This commit is contained in:
Gray Mackall
2024-08-20 14:33:12 -07:00
committed by GitHub
parent 5a87890277
commit ef9cd32f5a
51 changed files with 403 additions and 280 deletions

View File

@@ -80,6 +80,7 @@ final List<GradleHandledError> gradleErrors = <GradleHandledError>[
incompatibleJavaAndGradleVersionsHandler,
remoteTerminatedHandshakeHandler,
couldNotOpenCacheDirectoryHandler,
incompatibleCompileSdk35AndAgpVersionHandler,
];
const String _boxTitle = 'Flutter Fix';
@@ -640,3 +641,26 @@ final GradleHandledError couldNotOpenCacheDirectoryHandler = GradleHandledError(
},
eventLabel: 'could-not-open-cache-directory',
);
@visibleForTesting
final GradleHandledError incompatibleCompileSdk35AndAgpVersionHandler = GradleHandledError(
test: (String line) => line.contains('RES_TABLE_TYPE_TYPE entry offsets overlap actual entry data'),
handler: ({
required String line,
required FlutterProject project,
required bool usesAndroidX,
}) async {
globals.printBox(
'${globals.logger.terminal.warningMark} Using compileSdk 35 requires Android Gradle Plugin (AGP) 8.1.0 or higher.'
' \n Please upgrade to a newer AGP version. The version of AGP that your project uses is likely'
" defined in:\n${project.android.settingsGradleFile.path},\nin the 'plugins' closure. \n Alternatively, if your "
'project was created with an older version of the templates, it is likely \nin the buildscript.dependencies '
'closure of the top-level build.gradle:\n${project.android.hostAppGradleFile.path}.\n\n Finally, if you have a'
' strong reason to avoid upgrading AGP, you can temporarily lower the compileSdk version in the following file:\n${project.android.appGradleFile.path}',
title: _boxTitle,
);
return GradleBuildStatus.exit;
},
eventLabel: 'incompatible-compile-sdk-and-agp',
);

View File

@@ -38,10 +38,10 @@ const String templateKotlinGradlePluginVersion = '1.8.22';
// so new versions are picked up after a Flutter upgrade.
//
// Please see the README before changing any of these values.
const String compileSdkVersion = '34';
const String compileSdkVersion = '35';
const String minSdkVersion = '21';
const String targetSdkVersion = '34';
const String ndkVersion = '23.1.7779620';
const String targetSdkVersion = '35';
const String ndkVersion = '26.1.10909125';
// Update these when new major versions of Java are supported by new Gradle