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
fed35b4d
Unverified
Commit
fed35b4d
authored
Mar 25, 2021
by
Gurjinder Partola
Committed by
GitHub
Mar 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Add support for versioned Android cmdline tools (#78253)
parent
389a3fa5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
12 deletions
+63
-12
android_sdk.dart
packages/flutter_tools/lib/src/android/android_sdk.dart
+43
-12
android_sdk_test.dart
...er_tools/test/general.shard/android/android_sdk_test.dart
+20
-0
No files found.
packages/flutter_tools/lib/src/android/android_sdk.dart
View file @
fed35b4d
...
...
@@ -261,23 +261,57 @@ class AndroidSdk {
return
null
;
}
String
get
AvdManagerPath
(
)
{
final
String
binaryName
=
globals
.
platform
.
isWindows
?
'avdmanager.bat'
:
'avdmanager'
;
final
File
cmdlineToolsBinary
=
directory
String
get
CmdlineToolsPath
(
String
binaryName
)
{
// First look for the latest version of the command-line tools
final
File
cmdlineTools
Latest
Binary
=
directory
.
childDirectory
(
'cmdline-tools'
)
.
childDirectory
(
'latest'
)
.
childDirectory
(
'bin'
)
.
childFile
(
binaryName
);
if
(
cmdlineToolsBinary
.
existsSync
())
{
return
cmdlineToolsBinary
.
path
;
if
(
cmdlineToolsLatestBinary
.
existsSync
())
{
return
cmdlineToolsLatestBinary
.
path
;
}
// Next look for the highest version of the command-line tools
final
Directory
cmdlineToolsDir
=
directory
.
childDirectory
(
'cmdline-tools'
);
if
(
cmdlineToolsDir
.
existsSync
())
{
final
List
<
Version
>
cmdlineTools
=
cmdlineToolsDir
.
listSync
()
.
whereType
<
Directory
>()
.
map
((
Directory
subDirectory
)
{
try
{
return
Version
.
parse
(
subDirectory
.
basename
);
}
on
Exception
{
return
null
;
}
})
.
where
((
Version
version
)
=>
version
!=
null
)
.
toList
();
cmdlineTools
.
sort
();
for
(
final
Version
cmdlineToolsVersion
in
cmdlineTools
.
reversed
)
{
final
File
cmdlineToolsBinary
=
directory
.
childDirectory
(
'cmdline-tools'
)
.
childDirectory
(
cmdlineToolsVersion
.
toString
())
.
childDirectory
(
'bin'
)
.
childFile
(
binaryName
);
if
(
cmdlineToolsBinary
.
existsSync
())
{
return
cmdlineToolsBinary
.
path
;
}
}
}
// Finally fallback to the old SDK tools
final
File
toolsBinary
=
directory
.
childDirectory
(
'tools'
).
childDirectory
(
'bin'
).
childFile
(
binaryName
);
if
(
toolsBinary
.
existsSync
())
{
return
toolsBinary
.
path
;
}
return
null
;
}
String
getAvdManagerPath
()
=>
getCmdlineToolsPath
(
globals
.
platform
.
isWindows
?
'avdmanager.bat'
:
'avdmanager'
);
/// Sets up various paths used internally.
///
/// This method should be called in a case where the tooling may have updated
...
...
@@ -354,14 +388,11 @@ class AndroidSdk {
final
String
executable
=
globals
.
platform
.
isWindows
?
'sdkmanager.bat'
:
'sdkmanager'
;
final
File
cmdlineTool
=
directory
.
childDirectory
(
'cmdline-tools'
)
.
childDirectory
(
'latest'
)
.
childDirectory
(
'bin'
)
.
childFile
(
executable
);
if
(
cmdlineTool
.
existsSync
())
{
return
cmdlineTool
.
path
;
final
String
path
=
getCmdlineToolsPath
(
executable
);
if
(
path
!=
null
)
{
return
path
;
}
// If no binary was found, return the default location
return
directory
.
childDirectory
(
'tools'
)
.
childDirectory
(
'bin'
)
...
...
packages/flutter_tools/test/general.shard/android/android_sdk_test.dart
View file @
fed35b4d
...
...
@@ -80,6 +80,26 @@ void main() {
Config:
()
=>
config
,
});
testUsingContext
(
'returns sdkmanager path under cmdline tools (highest version) on Linux/macOS'
,
()
{
sdkDir
=
MockAndroidSdk
.
createSdkDirectory
();
config
.
setValue
(
'android-sdk'
,
sdkDir
.
path
);
final
AndroidSdk
sdk
=
AndroidSdk
.
locateAndroidSdk
();
final
List
<
String
>
versions
=
<
String
>[
'3.0'
,
'2.1'
,
'1.0'
];
for
(
final
String
version
in
versions
)
{
fileSystem
.
file
(
fileSystem
.
path
.
join
(
sdk
.
directory
.
path
,
'cmdline-tools'
,
version
,
'bin'
,
'sdkmanager'
)
).
createSync
(
recursive:
true
);
}
expect
(
sdk
.
sdkManagerPath
,
fileSystem
.
path
.
join
(
sdk
.
directory
.
path
,
'cmdline-tools'
,
'3.0'
,
'bin'
,
'sdkmanager'
));
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
),
Config:
()
=>
config
,
});
testUsingContext
(
'Caches adb location after first access'
,
()
{
sdkDir
=
MockAndroidSdk
.
createSdkDirectory
();
config
.
setValue
(
'android-sdk'
,
sdkDir
.
path
);
...
...
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