-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add warning for bumping Android SDK version to match plugins #92451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would need to get the max compileSdkVersion for each plugin, then check if it's grater than the project's compileSdkVersion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you mean versus warning for each plugin whose compileSdkVersion is larger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right. I think the warning is useful, so feel free to keep it! I think providing a message in this form will be helpful:
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart#L765-L774
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if plugin A requires 31 and plugin B requires 32, the app should bump to 32. what do you think about printing a single message at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that since the message is generated from Gradle, the error message that we would (otherwise) add to this dart file isn't necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I was thinking:
int maxPluginCompileSdkVersion = project.android.compileSdkVersion // TODO parse as int.
int processedPlugins = getPluginList().size()
getPluginList().each { plugin ->
Project pluginProject = project.rootProject.findProject(plugin.key)
pluginProject.afterEvaluate {
int pluginCompileSdkVersion = pluginProject.android.compileSdkVersion // TODO parse as int.
maxPluginCompileSdkVersion = max(maxPluginCompileSdkVersion, pluginCompileSdkVersion)
processedPlugins--
if (processedPlugins == 0) {
if (maxPluginCompileSdkVersion > project.android.compileSdkVersion) {
// Print error message.
}
}
}
}74f369c to
0722850
Compare
| android { | ||
| compileSdkVersion 30 | ||
| compileSdkVersion 31 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was there an issue with the current compileSdkVersion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this test is looking for a specific failure, and without bumping this version, my error was given before giving the failure expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, but the test was still passing, right? Your PR is mostly adding more errors to the stderr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the test was failing. @GaryQian can you provide some more context here?
| ], workingDirectory: projectAppDir.path); | ||
|
|
||
| // Check error message is thrown | ||
| final RegExp charactersToIgnore = RegExp(r'\|/|[\n]'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these characaters are also valid in the test. It could use Dart multiline strings if that is easier. e.g.
contains('''One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to ${projectGradleFile.path}:
android {
compileSdkVersion 31
}
''')
...ges/flutter_tools/test/integration.shard/android_plugin_compilesdkversion_mismatch_test.dart
Outdated
Show resolved
Hide resolved
...ges/flutter_tools/test/integration.shard/android_plugin_compilesdkversion_mismatch_test.dart
Outdated
Show resolved
Hide resolved
...ges/flutter_tools/test/integration.shard/android_plugin_compilesdkversion_mismatch_test.dart
Outdated
Show resolved
Hide resolved
...ges/flutter_tools/test/integration.shard/android_plugin_compilesdkversion_mismatch_test.dart
Outdated
Show resolved
Hide resolved
...ges/flutter_tools/test/integration.shard/android_plugin_compilesdkversion_mismatch_test.dart
Outdated
Show resolved
Hide resolved
…ompilesdkversion_mismatch_test.dart Co-authored-by: Emmanuel Garcia <[email protected]>
…ompilesdkversion_mismatch_test.dart Co-authored-by: Emmanuel Garcia <[email protected]>
blasten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % nit
Co-authored-by: Emmanuel Garcia <[email protected]>
Logs a warning when Flutter project's Android SDK version is below that of a plugin the project has as a dependency. This will be needed as plugin compileSdkVersions are bumped to support Android S+.
Fixes #91771