diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md index c43f2ab7e91..737a601ac7c 100644 --- a/packages/camera/camera_android/CHANGELOG.md +++ b/packages/camera/camera_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.10+8 + +* Restores compileSdk version to flutter.compileSdkVersion. + ## 0.10.10+7 * Updates minimum supported SDK version to Flutter 3.35. diff --git a/packages/camera/camera_android/android/build.gradle b/packages/camera/camera_android/android/build.gradle index 9d5c41c6dce..c0e8e053120 100644 --- a/packages/camera/camera_android/android/build.gradle +++ b/packages/camera/camera_android/android/build.gradle @@ -31,7 +31,7 @@ buildFeatures { buildConfig true } namespace = "io.flutter.plugins.camera" - compileSdk = 36 + compileSdk = flutter.compileSdkVersion defaultConfig { minSdkVersion 24 diff --git a/packages/camera/camera_android/pubspec.yaml b/packages/camera/camera_android/pubspec.yaml index b9a0da19604..c9dc7d3ee8c 100644 --- a/packages/camera/camera_android/pubspec.yaml +++ b/packages/camera/camera_android/pubspec.yaml @@ -3,7 +3,7 @@ description: Android implementation of the camera plugin. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.10.10+7 +version: 0.10.10+8 environment: sdk: ^3.9.0 diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart index 6f83d4dbecb..a797cf95f88 100644 --- a/script/tool/lib/src/gradle_check_command.dart +++ b/script/tool/lib/src/gradle_check_command.dart @@ -427,6 +427,7 @@ for more details.'''; final RegExp legacySettingPattern = RegExp(r'^\s*compileSdkVersion'); final String? compileSdkLine = gradleLines .firstWhereOrNull((String line) => linePattern.hasMatch(line)); + if (compileSdkLine == null) { // Equals regex not found check for method pattern. final RegExp compileSpacePattern = RegExp(r'^\s*compileSdk'); @@ -467,6 +468,28 @@ for more details.'''; 'version to at least 3.27.'); return false; } + } else { + // Extract compileSdkVersion and check if it is higher than flutter.compileSdkVersion. + final RegExp numericVersionPattern = RegExp(r'=\s*(\d+)'); + final RegExpMatch? versionMatch = + numericVersionPattern.firstMatch(compileSdkLine); + + if (versionMatch != null) { + final int compileSdkVersion = int.parse(versionMatch.group(1)!); + const int minCompileSdkVersion = 36; + + if (compileSdkVersion < minCompileSdkVersion) { + printError( + '${indentation}compileSdk version $compileSdkVersion is too low. ' + 'Minimum required version is $minCompileSdkVersion.\n' + "${indentation}Please update this package's compileSdkVersion to at least " + '$minCompileSdkVersion or use flutter.compileSdkVersion.'); + return false; + } + } else { + printError('${indentation}Unable to parse compileSdk version number.'); + return false; + } } return true; } diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart index c92a6ad2220..b7e0b547abe 100644 --- a/script/tool/test/gradle_check_command_test.dart +++ b/script/tool/test/gradle_check_command_test.dart @@ -45,7 +45,7 @@ void main() { bool warningsConfigured = true, bool useDeprecatedCompileSdkVersion = false, bool usePropertyAssignment = true, - String compileSdk = '33', + String compileSdk = '36', }) { final File buildGradle = package .platformDirectory(FlutterPlatform.android) @@ -997,12 +997,14 @@ dependencies { }); group('compileSdk check', () { - test('passes if set to a number', () async { + test('passes if set to a version higher than flutter.compileSdkVersion', + () async { const String packageName = 'a_package'; final RepositoryPackage package = createFakePackage(packageName, packagesDir, isFlutter: true); + // Current flutter.compileSdkVersion is 36. writeFakePluginBuildGradle(package, - includeLanguageVersion: true, compileSdk: '35'); + includeLanguageVersion: true, compileSdk: '37'); writeFakeManifest(package); final RepositoryPackage example = package.getExamples().first; writeFakeExampleBuildGradles(example, pluginName: packageName); @@ -1044,6 +1046,37 @@ dependencies { ); }); + test('fails if set to a version lower than flutter.compileSdkVersion', + () async { + const String packageName = 'a_package'; + final RepositoryPackage package = + createFakePackage(packageName, packagesDir, isFlutter: true); + // Current flutter.compileSdkVersion is 36. + const String minCompileSdkVersion = '36'; + const String testCompileSdkVersion = '35'; + writeFakePluginBuildGradle(package, + includeLanguageVersion: true, compileSdk: testCompileSdkVersion); + writeFakeManifest(package); + final RepositoryPackage example = package.getExamples().first; + writeFakeExampleBuildGradles(example, pluginName: packageName); + writeFakeManifest(example, isApp: true); + + Error? commandError; + final List output = await runCapturingPrint( + runner, ['gradle-check'], errorHandler: (Error e) { + commandError = e; + }); + + expect(commandError, isA()); + expect( + output, + containsAllInOrder([ + contains('compileSdk version $testCompileSdkVersion is too low. ' + 'Minimum required version is $minCompileSdkVersion.'), + ]), + ); + }); + test('fails if set to flutter.compileSdkVersion with Flutter <3.27', () async { const String packageName = 'a_package';