Skip to content

Fix regression in NDK version checking #166998

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

Merged
merged 3 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ Future<TaskResult> buildFlutterApkWithSpecifiedDependencyVersions({
.replaceFirst(kgpReplacementString, versions.kotlinVersion);
await gradleSettingsFile.writeAsString(settingsContent, flush: true);

section('Add a dependency on a plugin');
await flutter(
'pub',
options: <String>['add', 'shared_preferences_android:2.4.9'], // Chosen randomly.
workingDirectory: appPath,
);

// Ensure that gradle files exists from templates.
section(
"Ensure 'flutter build apk' succeeds with Gradle ${versions.gradleVersion}, AGP ${versions.agpVersion}, and Kotlin ${versions.kotlinVersion}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,16 @@ object FlutterPluginUtils {
getCompileSdkFromProject(project).toIntOrNull() ?: Int.MAX_VALUE

var maxPluginCompileSdkVersion = projectCompileSdkVersion
val projectNdkVersion =
getAndroidExtension(project).ndkVersion
// TODO(gmackall): This should be updated to reflect newer templates.
// The default for AGP 4.1.0 used in old templates.
val ndkVersionIfUnspecified = "21.1.6352462"

// TODO(gmackall): We can remove this elvis when our minimum AGP is >= 8.2.
// This value (ndkVersion) is nullable on AGP versions below that.
// See https://developer.android.com/reference/tools/gradle-api/8.1/com/android/build/api/dsl/CommonExtension#ndkVersion().
@Suppress("USELESS_ELVIS")
val projectNdkVersion: String =
getAndroidExtension(project).ndkVersion // ?: ndkVersionIfUnspecified
Copy link
Member Author

@gmackall gmackall Apr 11, 2025

Choose a reason for hiding this comment

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

I commented out the use of ndkVersionIfUnspecified to locally verify that the test was properly testing the issue, but made the mistake of pushing that change in addition to the change to the test

Copy link
Member Author

Choose a reason for hiding this comment

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

And this test only runs in postsubmit so it wasn't caught on the presubmits

Copy link
Member Author

Choose a reason for hiding this comment

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

Will add both

dev/devicelab/lib/framework/dependency_smoke_test_task_definition.dart
packages/flutter_tools/gradle/**

to the runif for the java 11 and 17 versions of this task in the reland to ensure this doesn't happen again

var maxPluginNdkVersion = projectNdkVersion
var numProcessedPlugins = pluginList.size
val pluginsWithHigherSdkVersion = mutableListOf<PluginVersionPair>()
Expand All @@ -543,8 +551,13 @@ object FlutterPluginUtils {
)
)
}

// TODO(gmackall): We can remove this elvis when our minimum AGP is >= 8.2.
// This value (ndkVersion) is nullable on AGP versions below that.
// See https://developer.android.com/reference/tools/gradle-api/8.1/com/android/build/api/dsl/CommonExtension#ndkVersion().
@Suppress("USELESS_ELVIS")
val pluginNdkVersion: String =
getAndroidExtension(pluginProject).ndkVersion
getAndroidExtension(pluginProject).ndkVersion // ?: ndkVersionIfUnspecified
maxPluginNdkVersion =
VersionUtils.mostRecentSemanticVersion(
pluginNdkVersion,
Expand Down