Skip to content

Commit 47c6e40

Browse files
Add Android specific sub-step to validate the Android sdk path has no spaces (flutter#170829)
The android sdk cannot have spaces in it <img width="704" alt="Screenshot 2025-06-18 at 11 41 12 AM" src="https://github.com/user-attachments/assets/2d78599d-8417-4af6-8bc8-f9037f4aab01" /> Add a validation step that it doesn't as it currently blocks building an app bundle (as we need the apkanalyzer now, after the debug symbol changes). ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --------- Co-authored-by: Gray Mackall <mackall@google.com>
1 parent 5706259 commit 47c6e40

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,15 @@ class AndroidSdk {
239239
return <String>[msg.toString()];
240240
}
241241

242+
if (directory.absolute.path.contains(' ')) {
243+
final String androidSdkSpaceWarning =
244+
'Android SDK location currently '
245+
'contains spaces, which is not supported by the Android SDK as it '
246+
'causes problems with NDK tools. Try moving it from '
247+
'${directory.absolute.path} to a path without spaces.';
248+
return <String>[androidSdkSpaceWarning];
249+
}
250+
242251
return latestVersion!.validateSdkWellFormed();
243252
}
244253

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ const String _kBuildVariantRegexGroupName = 'variant';
5555
const String _kBuildVariantTaskName = 'printBuildVariants';
5656
@visibleForTesting
5757
const String failedToStripDebugSymbolsErrorMessage = r'''
58-
Release app bundle failed to strip debug symbols from native libraries. Please run flutter doctor and ensure that the Android toolchain does not report any issues.
58+
Release app bundle failed to strip debug symbols from native libraries.
59+
Please run flutter doctor and ensure that the Android toolchain does not
60+
report any issues.
5961
6062
Otherwise, file an issue at https://github.com/flutter/flutter/issues.''';
6163

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,35 @@ void main() {
315315
},
316316
);
317317

318+
testUsingContext(
319+
'detects spaces in Android SDK path',
320+
() {
321+
final Directory sdkDir = createSdkDirectory(
322+
fileSystem: fileSystem,
323+
directoryName: 'flutter_mock_android_sdk with spaces.',
324+
);
325+
processManager.addCommand(
326+
const FakeCommand(
327+
command: <String>[
328+
'/.tmp_rand0/flutter_mock_android_sdk with spaces.rand0/cmdline-tools/latest/bin/sdkmanager',
329+
'--version',
330+
],
331+
),
332+
);
333+
config.setValue('android-sdk', sdkDir.path);
334+
335+
final List<String> validationIssues =
336+
AndroidSdk.locateAndroidSdk()!.validateSdkWellFormed();
337+
expect(validationIssues.first, contains('Android SDK location currently contains spaces'));
338+
},
339+
overrides: <Type, Generator>{
340+
FileSystem: () => fileSystem,
341+
ProcessManager: () => processManager,
342+
Config: () => config,
343+
Platform: () => FakePlatform(),
344+
},
345+
);
346+
318347
testUsingContext(
319348
'does not throw on sdkmanager version check failure',
320349
() {
@@ -621,9 +650,10 @@ Directory createSdkDirectory({
621650
required FileSystem fileSystem,
622651
String buildProp = _buildProp,
623652
Platform? platform,
653+
String directoryName = 'flutter_mock_android_sdk.',
624654
}) {
625655
platform ??= globals.platform;
626-
final Directory dir = fileSystem.systemTempDirectory.createTempSync('flutter_mock_android_sdk.');
656+
final Directory dir = fileSystem.systemTempDirectory.createTempSync(directoryName);
627657
final String exe = platform.isWindows ? '.exe' : '';
628658
final String bat = platform.isWindows ? '.bat' : '';
629659

0 commit comments

Comments
 (0)