Skip to content

Commit d839cde

Browse files
DanielEdrisiangoderbauer
authored andcommitted
Updated androidMissingSdkInstructions error message (flutter#65964)
1 parent 1e2a627 commit d839cde

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

packages/flutter_tools/lib/src/android/android_workflow.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class AndroidValidator extends DoctorValidator {
167167
} else {
168168
// Instruct user to set [kAndroidSdkRoot] and not deprecated [kAndroidHome]
169169
// See https://github.com/flutter/flutter/issues/39301
170-
messages.add(ValidationMessage.error(_userMessages.androidMissingSdkInstructions(kAndroidSdkRoot, _platform)));
170+
messages.add(ValidationMessage.error(_userMessages.androidMissingSdkInstructions(_platform)));
171171
}
172172
return ValidationResult(ValidationType.missing, messages);
173173
}
@@ -198,7 +198,7 @@ class AndroidValidator extends DoctorValidator {
198198
_androidSdk.latestVersion.platformName,
199199
_androidSdk.latestVersion.buildToolsVersionName)));
200200
} else {
201-
messages.add(ValidationMessage.error(_userMessages.androidMissingSdkInstructions(kAndroidHome, _platform)));
201+
messages.add(ValidationMessage.error(_userMessages.androidMissingSdkInstructions(_platform)));
202202
}
203203

204204
if (_platform.environment.containsKey(kAndroidHome)) {

packages/flutter_tools/lib/src/base/user_messages.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ class UserMessages {
6969
String androidBadSdkDir(String envKey, String homeDir) =>
7070
'$envKey = $homeDir\n'
7171
'but Android SDK not found at this location.';
72-
String androidMissingSdkInstructions(String envKey, Platform platform) =>
72+
String androidMissingSdkInstructions(Platform platform) =>
7373
'Unable to locate Android SDK.\n'
7474
'Install Android Studio from: https://developer.android.com/studio/index.html\n'
7575
'On first launch it will assist you in installing the Android SDK components.\n'
7676
'(or visit ${_androidSdkInstallUrl(platform)} for detailed instructions).\n'
77-
'If the Android SDK has been installed to a custom location, set $envKey to that location.\n'
78-
'You may also want to add it to your PATH environment variable.\n';
77+
'If the Android SDK has been installed to a custom location, please use\n'
78+
'`flutter config --android-sdk` to update to that location.\n';
7979
String androidSdkLocation(String directory) => 'Android SDK at $directory';
8080
String androidSdkPlatformToolsVersion(String platform, String tools) =>
8181
'Platform $platform, build-tools $tools';

packages/flutter_tools/test/general.shard/android/android_workflow_test.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,15 @@ void main() {
329329
validationResult.messages.last.message,
330330
errorMessage,
331331
);
332+
expect(
333+
validationResult.messages.any(
334+
(ValidationMessage message) => message.message.contains('Unable to locate Android SDK')
335+
),
336+
false,
337+
);
332338
});
333339

334-
testWithoutContext('Mentions `kAndroidSdkRoot if user has no AndroidSdk`', () async {
340+
testWithoutContext('Mentions `flutter config --android-sdk if user has no AndroidSdk`', () async {
335341
final ValidationResult validationResult = await AndroidValidator(
336342
androidSdk: null,
337343
androidStudio: null,
@@ -343,7 +349,7 @@ void main() {
343349
).validate();
344350
expect(
345351
validationResult.messages.any(
346-
(ValidationMessage message) => message.message.contains(kAndroidSdkRoot)
352+
(ValidationMessage message) => message.message.contains('flutter config --android-sdk')
347353
),
348354
true,
349355
);

packages/flutter_tools/test/general.shard/base/user_messages_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void main() {
2323

2424
testWithoutContext('Android installation instructions', () {
2525
final UserMessages userMessages = UserMessages();
26-
_checkInstallationURL((Platform platform) => userMessages.androidMissingSdkInstructions('ANDROID_SDK_ROOT', platform));
26+
_checkInstallationURL((Platform platform) => userMessages.androidMissingSdkInstructions(platform));
2727
_checkInstallationURL((Platform platform) => userMessages.androidSdkInstallHelp(platform));
2828
_checkInstallationURL((Platform platform) => userMessages.androidMissingSdkManager('/', platform));
2929
_checkInstallationURL((Platform platform) => userMessages.androidCannotRunSdkManager('/', '', platform));

0 commit comments

Comments
 (0)