Skip to content

Commit 40c34d2

Browse files
Devasyreidbakercamsim99
authored
Add regression test for plugin compileSdkExtension warning (flutter#191281)
## Description This closes out flutter#191081. The bogus "compiles against Android SDK 2147483647" warning was caused by `getCompileSdkFromProject` parsing the deprecated `compileSdkVersion` platform-hash string (`"android-36-ext19".substring(8).toIntOrNull() ?: Int.MAX_VALUE`). That codepath no longer exists: flutter#190957 (part of the AGP 9.1.0 migration stack) already rewrote `getCompileSdkFromProject` to read AGP's typed `compileSdk: Int?` / `compileSdkPreview: String?` DSL properties directly. Since `compileSdk` never folds in the extension suffix, the failure mode in flutter#191081 is now structurally impossible — no plugin's `compileSdkExtension` can leak into this comparison. What was missing was test coverage for exactly this scenario (a plugin with `compileSdkExtension` set, as required by AARs with a `minCompileSdkExtension` metadata constraint — e.g. `androidx.health.connect:connect-client`). This PR adds that regression test to `FlutterPluginUtilsTest.kt`, confirming `compileSdkExtension` plays no part in the resulting `CompileSdkVersion` or in `isHigherThan` comparisons, so a future refactor can't reintroduce the bug. No production code changes — this is test-only. ## Pre-launch Checklist - [x] I read the [Contributor Guide](https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md) and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene](https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md) wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide](https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md). - [x] I signed the [CLA](https://cla.developers.google.com/). - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making. Fixes flutter#191081 Co-authored-by: Devasy Patel <[email protected]> Co-authored-by: Reid Baker <[email protected]> Co-authored-by: Camille Simon <[email protected]>
1 parent e6f8019 commit 40c34d2

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎packages/flutter_tools/gradle/src/test/kotlin/FlutterPluginUtilsTest.kt‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,27 @@ class FlutterPluginUtilsTest {
686686
assertEquals("Baklava", result.toString())
687687
}
688688

689+
// Regression test for https://github.com/flutter/flutter/issues/191081: a plugin that also
690+
// sets compileSdkExtension (required by AARs with a minCompileSdkExtension AAR metadata
691+
// constraint, e.g. androidx.health.connect:connect-client) must not affect the reported
692+
// compile SDK. compileSdk and compileSdkExtension are distinct typed AGP properties, so the
693+
// extension level plays no part in this apiLevel/previewCodename result or in any downstream
694+
// isHigherThan comparison.
695+
@Test
696+
fun `getCompileSdkFromProject ignores compileSdkExtension`() {
697+
val project = mockk<Project>()
698+
val androidExtension = mockk<ApplicationExtension>()
699+
every { project.extensions.findByName("android") } returns androidExtension
700+
every { androidExtension.compileSdk } returns 36
701+
every { androidExtension.compileSdkPreview } returns null
702+
every { androidExtension.compileSdkExtension } returns 19
703+
val result = FlutterPluginUtils.getCompileSdkFromProject(project)
704+
assertEquals(CompileSdkVersion(apiLevel = 36, previewCodename = null), result)
705+
assertEquals("36", result.toString())
706+
assertFalse(result.isHigherThan(CompileSdkVersion(apiLevel = 37, previewCodename = null)))
707+
assertFalse(result.isHigherThan(CompileSdkVersion(apiLevel = 36, previewCodename = null)))
708+
}
709+
689710
@Test
690711
fun `getCompileSdkFromProject prioritizes preview and sanitizes when both compileSdk and compileSdkPreview are set`() {
691712
val project = mockk<Project>()

0 commit comments

Comments
 (0)