Skip to content

Commit 15acade

Browse files
authored
Revert hardcoded compilesdk back to flutter.compileSdkVersion in camera_android (#9668)
Merged hardcoded compileSdkVersion instead of using `flutter.compileSdkVersion`. Reverting back to `flutter.compileSdkVersion`. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent b7caa1d commit 15acade

File tree

5 files changed

+65
-5
lines changed

5 files changed

+65
-5
lines changed

packages/camera/camera_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.10+8
2+
3+
* Restores compileSdk version to flutter.compileSdkVersion.
4+
15
## 0.10.10+7
26

37
* Updates minimum supported SDK version to Flutter 3.35.

packages/camera/camera_android/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ buildFeatures {
3131
buildConfig true
3232
}
3333
namespace = "io.flutter.plugins.camera"
34-
compileSdk = 36
34+
compileSdk = flutter.compileSdkVersion
3535

3636
defaultConfig {
3737
minSdkVersion 24

packages/camera/camera_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.10.10+7
6+
version: 0.10.10+8
77

88
environment:
99
sdk: ^3.9.0

script/tool/lib/src/gradle_check_command.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ for more details.''';
427427
final RegExp legacySettingPattern = RegExp(r'^\s*compileSdkVersion');
428428
final String? compileSdkLine = gradleLines
429429
.firstWhereOrNull((String line) => linePattern.hasMatch(line));
430+
430431
if (compileSdkLine == null) {
431432
// Equals regex not found check for method pattern.
432433
final RegExp compileSpacePattern = RegExp(r'^\s*compileSdk');
@@ -467,6 +468,28 @@ for more details.''';
467468
'version to at least 3.27.');
468469
return false;
469470
}
471+
} else {
472+
// Extract compileSdkVersion and check if it is higher than flutter.compileSdkVersion.
473+
final RegExp numericVersionPattern = RegExp(r'=\s*(\d+)');
474+
final RegExpMatch? versionMatch =
475+
numericVersionPattern.firstMatch(compileSdkLine);
476+
477+
if (versionMatch != null) {
478+
final int compileSdkVersion = int.parse(versionMatch.group(1)!);
479+
const int minCompileSdkVersion = 36;
480+
481+
if (compileSdkVersion < minCompileSdkVersion) {
482+
printError(
483+
'${indentation}compileSdk version $compileSdkVersion is too low. '
484+
'Minimum required version is $minCompileSdkVersion.\n'
485+
"${indentation}Please update this package's compileSdkVersion to at least "
486+
'$minCompileSdkVersion or use flutter.compileSdkVersion.');
487+
return false;
488+
}
489+
} else {
490+
printError('${indentation}Unable to parse compileSdk version number.');
491+
return false;
492+
}
470493
}
471494
return true;
472495
}

script/tool/test/gradle_check_command_test.dart

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void main() {
4545
bool warningsConfigured = true,
4646
bool useDeprecatedCompileSdkVersion = false,
4747
bool usePropertyAssignment = true,
48-
String compileSdk = '33',
48+
String compileSdk = '36',
4949
}) {
5050
final File buildGradle = package
5151
.platformDirectory(FlutterPlatform.android)
@@ -997,12 +997,14 @@ dependencies {
997997
});
998998

999999
group('compileSdk check', () {
1000-
test('passes if set to a number', () async {
1000+
test('passes if set to a version higher than flutter.compileSdkVersion',
1001+
() async {
10011002
const String packageName = 'a_package';
10021003
final RepositoryPackage package =
10031004
createFakePackage(packageName, packagesDir, isFlutter: true);
1005+
// Current flutter.compileSdkVersion is 36.
10041006
writeFakePluginBuildGradle(package,
1005-
includeLanguageVersion: true, compileSdk: '35');
1007+
includeLanguageVersion: true, compileSdk: '37');
10061008
writeFakeManifest(package);
10071009
final RepositoryPackage example = package.getExamples().first;
10081010
writeFakeExampleBuildGradles(example, pluginName: packageName);
@@ -1044,6 +1046,37 @@ dependencies {
10441046
);
10451047
});
10461048

1049+
test('fails if set to a version lower than flutter.compileSdkVersion',
1050+
() async {
1051+
const String packageName = 'a_package';
1052+
final RepositoryPackage package =
1053+
createFakePackage(packageName, packagesDir, isFlutter: true);
1054+
// Current flutter.compileSdkVersion is 36.
1055+
const String minCompileSdkVersion = '36';
1056+
const String testCompileSdkVersion = '35';
1057+
writeFakePluginBuildGradle(package,
1058+
includeLanguageVersion: true, compileSdk: testCompileSdkVersion);
1059+
writeFakeManifest(package);
1060+
final RepositoryPackage example = package.getExamples().first;
1061+
writeFakeExampleBuildGradles(example, pluginName: packageName);
1062+
writeFakeManifest(example, isApp: true);
1063+
1064+
Error? commandError;
1065+
final List<String> output = await runCapturingPrint(
1066+
runner, <String>['gradle-check'], errorHandler: (Error e) {
1067+
commandError = e;
1068+
});
1069+
1070+
expect(commandError, isA<ToolExit>());
1071+
expect(
1072+
output,
1073+
containsAllInOrder(<Matcher>[
1074+
contains('compileSdk version $testCompileSdkVersion is too low. '
1075+
'Minimum required version is $minCompileSdkVersion.'),
1076+
]),
1077+
);
1078+
});
1079+
10471080
test('fails if set to flutter.compileSdkVersion with Flutter <3.27',
10481081
() async {
10491082
const String packageName = 'a_package';

0 commit comments

Comments
 (0)