Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ buildFeatures {
buildConfig true
}
namespace = "io.flutter.plugins.camera"
compileSdk = 36
compileSdk = flutter.compileSdkVersion

defaultConfig {
minSdkVersion 24
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions script/tool/lib/src/gradle_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -467,6 +468,28 @@ for more details.''';
'version to at least 3.27.');
return false;
}
} else {
// Extract compileSdkVersion and check if it higher than flutter.compileSdkVersion.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: if it is

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;
}
Expand Down
39 changes: 36 additions & 3 deletions script/tool/test/gradle_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<String> output = await runCapturingPrint(
runner, <String>['gradle-check'], errorHandler: (Error e) {
commandError = e;
});

expect(commandError, isA<ToolExit>());
expect(
output,
containsAllInOrder(<Matcher>[
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';
Expand Down