From 0984a7f04b458875f3c7610b031763c8933e150d Mon Sep 17 00:00:00 2001 From: Gray Mackall <34871572+gmackall@users.noreply.github.com> Date: Thu, 28 Mar 2024 17:31:01 -0700 Subject: [PATCH] Point kotlin message in `gradle_errors.dart` towards new place where templates define the kotlin version (#145936) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/flutter/flutter/issues/144454 For reference, after formatting it looks like: ``` ┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────────────────┐ │ [!] Your project requires a newer version of the Kotlin Gradle plugin. │ │ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update the │ │ version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of │ │ /Users/mackall/development/BugTesting/ELIMINATEME/blah/android/settings.gradle. │ │ │ │ Alternatively (if your project was created before Flutter 3.19), update │ │ /Users/mackall/development/BugTesting/ELIMINATEME/blah/android/build.gradle │ │ ext.kotlin_version = '' │ └────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` --- .../lib/src/android/gradle_errors.dart | 11 +++++++++-- .../android/gradle_errors_test.dart | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/gradle_errors.dart b/packages/flutter_tools/lib/src/android/gradle_errors.dart index 4bc3efaae3..97e1ce89fd 100644 --- a/packages/flutter_tools/lib/src/android/gradle_errors.dart +++ b/packages/flutter_tools/lib/src/android/gradle_errors.dart @@ -441,10 +441,17 @@ final GradleHandledError incompatibleKotlinVersionHandler = GradleHandledError( final File gradleFile = project.directory .childDirectory('android') .childFile('build.gradle'); + final File settingsFile = project.directory + .childDirectory('android') + .childFile('settings.gradle'); globals.printBox( '${globals.logger.terminal.warningMark} Your project requires a newer version of the Kotlin Gradle plugin.\n' - 'Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update ${gradleFile.path}:\n' - "ext.kotlin_version = ''", + 'Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update the \n' + 'version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of \n' + '${settingsFile.path}.\n\n' + 'Alternatively (if your project was created before Flutter 3.19), update \n' + '${gradleFile.path}\n' + "ext.kotlin_version = ''", title: _boxTitle, ); return GradleBuildStatus.exit; diff --git a/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart index 0669159660..ba1fe95b4a 100644 --- a/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart +++ b/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart @@ -814,13 +814,18 @@ Execution failed for task ':app:generateDebugFeatureTransitiveDeps'. expect( testLogger.statusText, contains( - '\n' - '┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────┐\n' - '│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │\n' - '│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │\n' - '│ update /android/build.gradle: │\n' - "│ ext.kotlin_version = '' │\n" - '└────────────────────────────────────────────────────────────────────────────────────────────┘\n' + '\n' + '┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐\n' + '│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │\n' + '│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │\n' + '│ update the │\n' + '│ version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of │\n' + '│ /android/settings.gradle. │\n' + '│ │\n' + '│ Alternatively (if your project was created before Flutter 3.19), update │\n' + '│ /android/build.gradle │\n' + "│ ext.kotlin_version = '' │\n" + '└──────────────────────────────────────────────────────────────────────────────────────────────┘\n' ) ); }, overrides: {