Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
34fa90b0
Unverified
Commit
34fa90b0
authored
Nov 06, 2018
by
jslavitz
Committed by
GitHub
Nov 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves SDK Search Error Messages (#23884)
* Improves error message and adds test.
parent
99374edc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
12 deletions
+73
-12
android_sdk.dart
packages/flutter_tools/lib/src/android/android_sdk.dart
+25
-12
android_sdk_test.dart
packages/flutter_tools/test/android/android_sdk_test.dart
+48
-0
No files found.
packages/flutter_tools/lib/src/android/android_sdk.dart
View file @
34fa90b0
...
...
@@ -317,14 +317,36 @@ class AndroidSdk {
String
get
avdManagerPath
=>
getAvdManagerPath
();
Directory
get
_platformsDir
=>
fs
.
directory
(
fs
.
path
.
join
(
directory
,
'platforms'
));
Iterable
<
Directory
>
get
_platforms
{
Iterable
<
Directory
>
platforms
=
<
Directory
>[];
if
(
_platformsDir
.
existsSync
())
{
platforms
=
_platformsDir
.
listSync
()
.
whereType
<
Directory
>();
}
return
platforms
;
}
/// Validate the Android SDK. This returns an empty list if there are no
/// issues; otherwise, it returns a list of issues found.
List
<
String
>
validateSdkWellFormed
()
{
if
(!
processManager
.
canRun
(
adbPath
))
return
<
String
>[
'Android SDK file not found:
$adbPath
.'
];
if
(
sdkVersions
.
isEmpty
||
latestVersion
==
null
)
return
<
String
>[
'Android SDK is missing command line tools; download from https://goo.gl/XxQghQ'
];
if
(
sdkVersions
.
isEmpty
||
latestVersion
==
null
)
{
final
StringBuffer
msg
=
StringBuffer
(
'No valid Android SDK platforms found in
${_platformsDir.path}
.'
);
if
(
_platforms
.
isEmpty
)
{
msg
.
write
(
' Directory was empty.'
);
}
else
{
msg
.
write
(
' Candidates were:
\n
'
);
msg
.
write
(
_platforms
.
map
((
Directory
dir
)
=>
' -
${dir.basename}
'
)
.
join
(
'
\n
'
));
}
return
<
String
>[
msg
.
toString
()];
}
return
latestVersion
.
validateSdkWellFormed
();
}
...
...
@@ -355,15 +377,6 @@ class AndroidSdk {
}
void
_init
()
{
Iterable
<
Directory
>
platforms
=
<
Directory
>[];
// android-22, ...
final
Directory
platformsDir
=
fs
.
directory
(
fs
.
path
.
join
(
directory
,
'platforms'
));
if
(
platformsDir
.
existsSync
())
{
platforms
=
platformsDir
.
listSync
()
.
whereType
<
Directory
>();
}
List
<
Version
>
buildTools
=
<
Version
>[];
// 19.1.0, 22.0.1, ...
final
Directory
buildToolsDir
=
fs
.
directory
(
fs
.
path
.
join
(
directory
,
'build-tools'
));
...
...
@@ -382,7 +395,7 @@ class AndroidSdk {
}
// Match up platforms with the best corresponding build-tools.
_sdkVersions
=
platforms
.
map
<
AndroidSdkVersion
>((
Directory
platformDir
)
{
_sdkVersions
=
_
platforms
.
map
<
AndroidSdkVersion
>((
Directory
platformDir
)
{
final
String
platformName
=
platformDir
.
basename
;
int
platformVersion
;
...
...
packages/flutter_tools/test/android/android_sdk_test.dart
View file @
34fa90b0
...
...
@@ -83,6 +83,23 @@ void main() {
ProcessManager:
()
=>
processManager
,
});
testUsingContext
(
'returns validate sdk is well formed'
,
()
{
sdkDir
=
MockBrokenAndroidSdk
.
createSdkDirectory
();
Config
.
instance
.
setValue
(
'android-sdk'
,
sdkDir
.
path
);
final
AndroidSdk
sdk
=
AndroidSdk
.
locateAndroidSdk
();
when
(
processManager
.
canRun
(
sdk
.
adbPath
)).
thenReturn
(
true
);
final
List
<
String
>
validationIssues
=
sdk
.
validateSdkWellFormed
();
expect
(
validationIssues
.
first
,
'No valid Android SDK platforms found in'
' /.tmp_rand0/flutter_mock_android_sdk.rand0/platforms. Candidates were:
\n
'
' - android-22
\n
'
' - android-23'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
processManager
,
});
testUsingContext
(
'does not throw on sdkmanager version check failure'
,
()
{
sdkDir
=
MockAndroidSdk
.
createSdkDirectory
();
Config
.
instance
.
setValue
(
'android-sdk'
,
sdkDir
.
path
);
...
...
@@ -164,3 +181,34 @@ void main() {
});
});
}
/// A broken SDK installation.
class
MockBrokenAndroidSdk
extends
Mock
implements
AndroidSdk
{
static
Directory
createSdkDirectory
({
bool
withAndroidN
=
false
,
String
withNdkDir
,
bool
withNdkSysroot
=
false
,
bool
withSdkManager
=
true
,
})
{
final
Directory
dir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_mock_android_sdk.'
);
_createSdkFile
(
dir
,
'platform-tools/adb'
);
_createSdkFile
(
dir
,
'build-tools/sda/aapt'
);
_createSdkFile
(
dir
,
'build-tools/af/aapt'
);
_createSdkFile
(
dir
,
'build-tools/ljkasd/aapt'
);
_createSdkFile
(
dir
,
'platforms/android-22/android.jar'
);
_createSdkFile
(
dir
,
'platforms/android-23/android.jar'
);
return
dir
;
}
static
void
_createSdkFile
(
Directory
dir
,
String
filePath
,
{
String
contents
})
{
final
File
file
=
dir
.
childFile
(
filePath
);
file
.
createSync
(
recursive:
true
);
if
(
contents
!=
null
)
{
file
.
writeAsStringSync
(
contents
,
flush:
true
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment