Add warning for bumping Android SDK version to match plugins#92451
Add warning for bumping Android SDK version to match plugins#92451fluttergithubbot merged 30 commits intoflutter:masterfrom
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.
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.
I assume you mean versus warning for each plugin whose compileSdkVersion is larger?
There was a problem hiding this comment.
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.
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.
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.
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.
was there an issue with the current compileSdkVersion?
There was a problem hiding this comment.
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.
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.
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.
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]>
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