user_messages.dart 21.4 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'context.dart';
6
import 'platform.dart';
7

8
UserMessages get userMessages => context.get<UserMessages>()!;
9 10 11

/// Class containing message strings that can be produced by Flutter tools.
class UserMessages {
12 13 14 15
  // Messages used in multiple components.
  String get flutterToolBugInstructions =>
      'Please report a bug at https://github.com/flutter/flutter/issues.';

16
  // Messages used in FlutterValidator
17
  String flutterStatusInfo(String? channel, String? version, String os, String locale) =>
18
      'Channel ${channel ?? 'unknown'}, ${version ?? 'Unknown'}, on $os, locale $locale';
19 20 21 22
  String flutterVersion(String version, String flutterRoot) =>
      'Flutter version $version at $flutterRoot';
  String flutterRevision(String revision, String age, String date) =>
      'Framework revision $revision ($age), $date';
23 24
  String flutterUpstreamRepositoryUrl(String url) => 'Upstream repository $url';
  String flutterGitUrl(String url) => 'FLUTTER_GIT_URL = $url';
25 26
  String engineRevision(String revision) => 'Engine revision $revision';
  String dartRevision(String revision) => 'Dart version $revision';
27 28
  String pubMirrorURL(String url) => 'Pub download mirror $url';
  String flutterMirrorURL(String url) => 'Flutter download mirror $url';
29 30 31 32 33 34
  String get flutterBinariesDoNotRun =>
      'Downloaded executables cannot execute on host.\n'
      'See https://github.com/flutter/flutter/issues/6207 for more information';
  String get flutterBinariesLinuxRepairCommands =>
      'On Debian/Ubuntu/Mint: sudo apt-get install lib32stdc++6\n'
      'On Fedora: dnf install libstdc++.i686\n'
35
      'On Arch: pacman -S lib32-gcc-libs';
36 37 38

  // Messages used in NoIdeValidator
  String get noIdeStatusInfo => 'No supported IDEs installed';
39 40 41 42 43
  List<String> get noIdeInstallationInfo => <String>[
    'IntelliJ - https://www.jetbrains.com/idea/',
    'Android Studio - https://developer.android.com/studio/',
    'VS Code - https://code.visualstudio.com/',
  ];
44 45 46 47 48

  // Messages used in IntellijValidator
  String intellijStatusInfo(String version) => 'version $version';
  String get intellijPluginInfo =>
      'For information about installing plugins, see\n'
49
      'https://flutter.dev/intellij-setup/#installing-the-plugins';
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  String intellijMinimumVersion(String minVersion) =>
      'This install is older than the minimum recommended version of $minVersion.';
  String intellijLocation(String installPath) => 'IntelliJ at $installPath';

  // Message used in IntellijValidatorOnMac
  String get intellijMacUnknownResult => 'Cannot determine if IntelliJ is installed';

  // Messages used in DeviceValidator
  String get devicesMissing => 'No devices available';
  String devicesAvailable(int devices) => '$devices available';

  // Messages used in AndroidValidator
  String androidCantRunJavaBinary(String javaBinary) => 'Cannot execute $javaBinary to determine the version';
  String get androidUnknownJavaVersion => 'Could not determine java version';
  String androidJavaVersion(String javaVersion) => 'Java version $javaVersion';
65
  String androidJavaMinimumVersion(String javaVersion) => 'Java version $javaVersion is older than the minimum recommended version of 1.8';
66 67 68 69 70 71 72 73 74
  String androidSdkLicenseOnly(String envKey) =>
      'Android SDK contains licenses only.\n'
      'Your first build of an Android application will take longer than usual, '
      'while gradle downloads the missing components. This functionality will '
      'only work if the licenses in the licenses folder in $envKey are valid.\n'
      'If the Android SDK has been installed to another location, set $envKey to that location.\n'
      'You may also want to add it to your PATH environment variable.\n\n'
      'Certain features, such as `flutter emulators` and `flutter devices`, will '
      'not work without the currently missing SDK components.';
75 76 77
  String androidBadSdkDir(String envKey, String homeDir) =>
      '$envKey = $homeDir\n'
      'but Android SDK not found at this location.';
78
  String androidMissingSdkInstructions(Platform platform) =>
79 80 81
      'Unable to locate Android SDK.\n'
      'Install Android Studio from: https://developer.android.com/studio/index.html\n'
      'On first launch it will assist you in installing the Android SDK components.\n'
82
      '(or visit ${_androidSdkInstallUrl(platform)} for detailed instructions).\n'
83 84
      'If the Android SDK has been installed to a custom location, please use\n'
      '`flutter config --android-sdk` to update to that location.\n';
85 86 87
  String androidSdkLocation(String directory) => 'Android SDK at $directory';
  String androidSdkPlatformToolsVersion(String platform, String tools) =>
      'Platform $platform, build-tools $tools';
88
  String androidSdkInstallHelp(Platform platform) =>
89
      'Try re-installing or updating your Android SDK,\n'
90
      'visit ${_androidSdkInstallUrl(platform)} for detailed instructions.';
91 92 93 94 95 96 97 98 99 100 101 102
  // Also occurs in AndroidLicenseValidator
  String androidStatusInfo(String version) => 'Android SDK version $version';

  // Messages used in AndroidLicenseValidator
  String get androidMissingJdk =>
      'No Java Development Kit (JDK) found; You must have the environment '
      'variable JAVA_HOME set and the java binary in your PATH. '
      'You can download the JDK from https://www.oracle.com/technetwork/java/javase/downloads/.';
  String androidJdkLocation(String location) => 'Java binary at: $location';
  String get androidLicensesAll => 'All Android licenses accepted.';
  String get androidLicensesSome => 'Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses';
  String get androidLicensesNone => 'Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses';
103
  String androidLicensesUnknown(Platform platform) =>
104
      'Android license status unknown.\n'
105 106
      'Run `flutter doctor --android-licenses` to accept the SDK licenses.\n'
      'See ${_androidSdkInstallUrl(platform)} for more details.';
107
  String androidSdkManagerOutdated(String managerPath) =>
108 109 110 111
      'A newer version of the Android SDK is required. To update, run:\n'
      '$managerPath --update\n';
  String androidLicensesTimeout(String managerPath) => 'Intentionally killing $managerPath';
  String get androidSdkShort => 'Unable to locate Android SDK.';
112
  String androidMissingSdkManager(String sdkManagerPath, Platform platform) =>
113 114
      'Android sdkmanager tool not found ($sdkManagerPath).\n'
      'Try re-installing or updating your Android SDK,\n'
115 116
      'visit ${_androidSdkInstallUrl(platform)} for detailed instructions.';
  String androidCannotRunSdkManager(String sdkManagerPath, String error, Platform platform) =>
117 118
      'Android sdkmanager tool was found, but failed to run ($sdkManagerPath): "$error".\n'
      'Try re-installing or updating your Android SDK,\n'
119 120
      'visit ${_androidSdkInstallUrl(platform)} for detailed instructions.';
  String androidSdkBuildToolsOutdated(String managerPath, int sdkMinVersion, String buildToolsMinVersion, Platform platform) =>
121
      'Flutter requires Android SDK $sdkMinVersion and the Android BuildTools $buildToolsMinVersion\n'
122
      'To update the Android SDK visit ${_androidSdkInstallUrl(platform)} for detailed instructions.';
123 124 125
  String get androidMissingCmdTools => 'cmdline-tools component is missing\n'
      'Run `path/to/sdkmanager --install "cmdline-tools;latest"`\n'
      'See https://developer.android.com/studio/command-line for more details.';
126 127 128 129 130 131 132 133

  // Messages used in AndroidStudioValidator
  String androidStudioVersion(String version) => 'version $version';
  String androidStudioLocation(String location) => 'Android Studio at $location';
  String get androidStudioNeedsUpdate => 'Try updating or re-installing Android Studio.';
  String get androidStudioResetDir =>
      'Consider removing your android-studio-dir setting by running:\n'
      'flutter config --android-studio-dir=';
134 135
  String get aaptNotFound =>
      'Could not locate aapt. Please ensure you have the Android buildtools installed.';
136 137 138 139 140

  // Messages used in NoAndroidStudioValidator
  String androidStudioMissing(String location) =>
      'android-studio-dir = $location\n'
      'but Android Studio not found at this location.';
141
  String androidStudioInstallation(Platform platform) =>
142
      'Android Studio not found; download from https://developer.android.com/studio/index.html\n'
143
      '(or visit ${_androidSdkInstallUrl(platform)} for detailed instructions).';
144

145 146
  // Messages used in XcodeValidator
  String xcodeLocation(String location) => 'Xcode at $location';
147 148 149

  String xcodeOutdated(String currentVersion, String recommendedVersion) =>
      'Xcode $currentVersion out of date ($recommendedVersion is recommended).\n'
150
      'Download the latest version or update via the Mac App Store.';
151
  String get xcodeEula => "Xcode end user license agreement not signed; open Xcode or run the command 'sudo xcodebuild -license'.";
152
  String get xcodeMissingSimct =>
153
      'Xcode requires additional components to be installed in order to run.\n'
154 155
      'Launch Xcode and install additional required components when prompted or run:\n'
      '  sudo xcodebuild -runFirstLaunch';
156
  String get xcodeMissing =>
157 158
      'Xcode not installed; this is necessary for iOS development.\n'
      'Download at https://developer.apple.com/xcode/download/.';
159
  String get xcodeIncomplete =>
160 161 162 163
      'Xcode installation is incomplete; a full installation is necessary for iOS development.\n'
      'Download at: https://developer.apple.com/xcode/download/\n'
      'Or install Xcode via the App Store.\n'
      'Once installed, run:\n'
164 165
      '  sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer\n'
      '  sudo xcodebuild -runFirstLaunch';
166

167 168 169 170 171
  // Messages used in CocoaPodsValidator
  String cocoaPodsVersion(String version) => 'CocoaPods version $version';
  String cocoaPodsMissing(String consequence, String installInstructions) =>
      'CocoaPods not installed.\n'
      '$consequence\n'
172
      'To install $installInstructions';
173 174 175
  String cocoaPodsUnknownVersion(String consequence, String upgradeInstructions) =>
      'Unknown CocoaPods version installed.\n'
      '$consequence\n'
176
      'To upgrade $upgradeInstructions';
177 178
  String cocoaPodsOutdated(String currentVersion, String recVersion, String consequence, String upgradeInstructions) =>
      'CocoaPods $currentVersion out of date ($recVersion is recommended).\n'
179
      '$consequence\n'
180
      'To upgrade $upgradeInstructions';
181 182 183
  String cocoaPodsBrokenInstall(String consequence, String reinstallInstructions) =>
      'CocoaPods installed but not working.\n'
      '$consequence\n'
184
      'To re-install $reinstallInstructions';
185 186 187 188 189

  // Messages used in VsCodeValidator
  String vsCodeVersion(String version) => 'version $version';
  String vsCodeLocation(String location) => 'VS Code at $location';
  String vsCodeFlutterExtensionMissing(String url) => 'Flutter extension not installed; install from\n$url';
190

191 192 193
  // Messages used in VisualStudioValidator
  String visualStudioVersion(String name, String version) => '$name version $version';
  String visualStudioLocation(String location) => 'Visual Studio at $location';
194
  String windows10SdkVersion(String version) => 'Windows 10 SDK version $version';
195 196 197
  String visualStudioMissingComponents(String workload, List<String> components) =>
      'Visual Studio is missing necessary components. Please re-run the '
      'Visual Studio installer for the "$workload" workload, and include these components:\n'
198 199 200 201 202
      '  ${components.join('\n  ')}\n'
      '  Windows 10 SDK';
  String get windows10SdkNotFound =>
      'Unable to locate a Windows 10 SDK. If building fails, install the Windows 10 SDK in Visual Studio.';
  String visualStudioMissing(String workload) =>
203
      'Visual Studio not installed; this is necessary for Windows development.\n'
204
      'Download at https://visualstudio.microsoft.com/downloads/.\n'
205 206
      'Please install the "$workload" workload, including all of its default components';
  String visualStudioTooOld(String minimumVersion, String workload) =>
207 208
      'Visual Studio $minimumVersion or later is required.\n'
      'Download at https://visualstudio.microsoft.com/downloads/.\n'
209
      'Please install the "$workload" workload, including all of its default components';
210 211 212 213 214 215
  String get visualStudioIsPrerelease => 'The current Visual Studio installation is a pre-release version. It may not be '
      'supported by Flutter yet.';
  String get visualStudioNotLaunchable =>
      'The current Visual Studio installation is not launchable. Please reinstall Visual Studio.';
  String get visualStudioIsIncomplete => 'The current Visual Studio installation is incomplete. Please reinstall Visual Studio.';
  String get visualStudioRebootRequired => 'Visual Studio requires a reboot of your system to complete installation.';
216

217 218 219 220 221 222 223 224 225 226 227 228 229 230
  // Messages used in LinuxDoctorValidator
  String get clangMissing => 'clang++ is required for Linux development.\n'
      'It is likely available from your distribution (e.g.: apt install clang), or '
      'can be downloaded from https://releases.llvm.org/';
  String clangTooOld(String minimumVersion) => 'clang++ $minimumVersion or later is required.';
  String get cmakeMissing => 'CMake is required for Linux development.\n'
      'It is likely available from your distribution (e.g.: apt install cmake), or '
      'can be downloaded from https://cmake.org/download/';
  String cmakeTooOld(String minimumVersion) => 'cmake $minimumVersion or later is required.';
  String ninjaVersion(String version) => 'ninja version $version';
  String get ninjaMissing => 'ninja is required for Linux development.\n'
      'It is likely available from your distribution (e.g.: apt install ninja-build), or '
      'can be downloaded from https://github.com/ninja-build/ninja/releases';
  String ninjaTooOld(String minimumVersion) => 'ninja $minimumVersion or later is required.';
231
  String pkgConfigVersion(String version) => 'pkg-config version $version';
Taha Tesser's avatar
Taha Tesser committed
232
  String get pkgConfigMissing => 'pkg-config is required for Linux development.\n'
233 234 235 236 237
      'It is likely available from your distribution (e.g.: apt install pkg-config), or '
      'can be downloaded from https://www.freedesktop.org/wiki/Software/pkg-config/';
  String pkgConfigTooOld(String minimumVersion) => 'pkg-config $minimumVersion or later is required.';
  String get gtkLibrariesMissing => 'GTK 3.0 development libraries are required for Linux development.\n'
      'They are likely available from your distribution (e.g.: apt install libgtk-3-dev)';
238

239 240 241 242 243 244 245 246 247
  // Messages used in FlutterCommand
  String flutterElapsedTime(String name, String elapsedTime) => '"flutter $name" took $elapsedTime.';
  String get flutterNoDevelopmentDevice =>
      "Unable to locate a development device; please run 'flutter doctor' "
      'for information about installing additional components.';
  String flutterNoMatchingDevice(String deviceId) => 'No devices found with name or id '
      "matching '$deviceId'";
  String get flutterNoDevicesFound => 'No devices found';
  String get flutterNoSupportedDevices => 'No supported devices connected.';
248 249 250
  String flutterMissPlatformProjects(List<String> unsupportedDevicesType) =>
      'If you would like your app to run on ${unsupportedDevicesType.join(' or ')}, consider running `flutter create .` to generate projects for these platforms.';
  String get flutterFoundButUnsupportedDevices => 'The following devices were found, but are not supported by this project:';
251 252
  String flutterFoundSpecifiedDevices(int count, String deviceId) =>
      'Found $count devices with name or id matching $deviceId:';
253 254
  String get flutterMultipleDevicesFound => 'Multiple devices found:';
  String flutterChooseDevice(int option, String name, String deviceId) => '[$option]: $name ($deviceId)';
255
  String get flutterChooseOne => 'Please choose one (To quit, press "q/Q")';
256 257 258 259 260 261 262 263 264
  String get flutterSpecifyDeviceWithAllOption =>
      'More than one device connected; please specify a device with '
      "the '-d <deviceId>' flag, or use '-d all' to act on all devices.";
  String get flutterSpecifyDevice =>
      'More than one device connected; please specify a device with '
      "the '-d <deviceId>' flag.";
  String get flutterNoConnectedDevices => 'No connected devices.';
  String get flutterNoPubspec =>
      'Error: No pubspec.yaml file found.\n'
265
      'This command should be run from the root of your Flutter project.';
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
  String flutterTargetFileMissing(String path) => 'Target file "$path" not found.';
  String get flutterBasePatchFlagsExclusive => 'Error: Only one of --baseline, --patch is allowed.';
  String get flutterBaselineRequiresTraceFile => 'Error: --baseline requires --compilation-trace-file to be specified.';
  String get flutterPatchRequiresTraceFile => 'Error: --patch requires --compilation-trace-file to be specified.';

  // Messages used in FlutterCommandRunner
  String runnerNoRoot(String error) => 'Unable to locate flutter root: $error';
  String runnerWrapColumnInvalid(dynamic value) =>
      'Argument to --wrap-column must be a positive integer. You supplied $value.';
  String runnerWrapColumnParseError(dynamic value) =>
      'Unable to parse argument --wrap-column=$value. Must be a positive integer.';
  String runnerBugReportFinished(String zipFileName) =>
      'Bug report written to $zipFileName.\n'
      'Warning: this bug report contains local paths, device identifiers, and log snippets.';
  String get runnerNoRecordTo => 'record-to location not specified';
  String get runnerNoReplayFrom => 'replay-from location not specified';
282 283
  String runnerNoEngineSrcDir(String enginePackageName, String engineEnvVar) =>
      'Unable to detect local Flutter engine src directory.\n'
284 285 286 287 288
      'Either specify a dependency_override for the $enginePackageName package in your pubspec.yaml and '
      'ensure --package-root is set if necessary, or set the \$$engineEnvVar environment variable, or '
      'use --local-engine-src-path to specify the path to the root of your flutter/engine repository.';
  String runnerNoEngineBuildDirInPath(String engineSourcePath) =>
      'Unable to detect a Flutter engine build directory in $engineSourcePath.\n'
289 290
      "Please ensure that $engineSourcePath is a Flutter engine 'src' directory and that "
      "you have compiled the engine in that directory, which should produce an 'out' directory";
291 292 293 294 295
  String get runnerLocalEngineRequired =>
      'You must specify --local-engine if you are using a locally built engine.';
  String runnerNoEngineBuild(String engineBuildPath) =>
      'No Flutter engine build found at $engineBuildPath.';
  String runnerWrongFlutterInstance(String flutterRoot, String currentDir) =>
296
      "Warning: the 'flutter' tool you are currently running is not the one from the current directory:\n"
297 298 299
      '  running Flutter  : $flutterRoot\n'
      '  current directory: $currentDir\n'
      'This can happen when you have multiple copies of flutter installed. Please check your system path to verify '
300
      "that you're running the expected version (run 'flutter --version' to see which flutter is on your path).\n";
301 302
  String runnerRemovedFlutterRepo(String flutterRoot, String flutterPath) =>
      'Warning! This package referenced a Flutter repository via the .packages file that is '
303
      "no longer available. The repository from which the 'flutter' tool is currently "
304 305 306 307 308 309
      'executing will be used instead.\n'
      '  running Flutter tool: $flutterRoot\n'
      '  previous reference  : $flutterPath\n'
      'This can happen if you deleted or moved your copy of the Flutter repository, or '
      'if it was on a volume that is no longer mounted or has been mounted at a '
      'different location. Please check your system path to verify that you are running '
310
      "the expected version (run 'flutter --version' to see which flutter is on your path).\n";
311
  String runnerChangedFlutterRepo(String flutterRoot, String flutterPath) =>
312
      "Warning! The 'flutter' tool you are currently running is from a different Flutter "
313
      'repository than the one last used by this package. The repository from which the '
314
      "'flutter' tool is currently executing will be used instead.\n"
315 316 317 318
      '  running Flutter tool: $flutterRoot\n'
      '  previous reference  : $flutterPath\n'
      'This can happen when you have multiple copies of flutter installed. Please check '
      'your system path to verify that you are running the expected version (run '
319
      "'flutter --version' to see which flutter is on your path).\n";
320 321 322 323 324 325 326 327
  String invalidVersionSettingHintMessage(String invalidVersion) =>
      'Invalid version $invalidVersion found, default value will be used.\n'
      'In pubspec.yaml, a valid version should look like: build-name+build-number.\n'
      'In Android, build-name is used as versionName while build-number used as versionCode.\n'
      'Read more about Android versioning at https://developer.android.com/studio/publish/versioning\n'
      'In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.\n'
      'Read more about iOS versioning at\n'
      'https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html\n';
328 329 330 331 332 333 334 335 336 337 338 339 340 341

  String _androidSdkInstallUrl(Platform platform) {
    const String baseUrl = 'https://flutter.dev/docs/get-started/install';
    const String fragment = '#android-setup';
    if (platform.isMacOS) {
      return '$baseUrl/macos$fragment';
    } else if (platform.isLinux) {
      return '$baseUrl/linux$fragment';
    } else if (platform.isWindows) {
      return '$baseUrl/windows$fragment';
    } else {
      return baseUrl;
    }
  }
342
}