Android: update to latest SDK cmdline-tools

Also, add the --sdk_root argument which is needed.

Change-Id: I85f9444b35bb31aed9670bd322f2754061cf70c6
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Assam Boudjelthia
2020-06-30 11:32:03 +03:00
parent 0cfb9e2bce
commit 560f5bfdc7
3 changed files with 24 additions and 14 deletions

View File

@@ -1,15 +1,15 @@
{ {
"common": { "common": {
"sdk_tools_url": { "sdk_tools_url": {
"linux": "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip", "linux": "https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip",
"linux_sha256": "92ffee5a1d98d856634e8b71132e8a95d96c83a63fde1099be3d86df3106def9", "linux_sha256": "89f308315e041c93a37a79e0627c47f21d5c5edbe5e80ea8dc0aac8a649e0e92",
"windows": "https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip", "windows": "https://dl.google.com/android/repository/commandlinetools-win-6609375_latest.zip",
"windows_sha256": "7e81d69c303e47a4f0e748a6352d85cd0c8fd90a5a95ae4e076b5e5f960d3c7a", "windows_sha256": "40bba20275180194bebf89bb58c74d712bb93cc401f36bd2f8f32383acf9826c",
"mac": "https://dl.google.com/android/repository/sdk-tools-darwin-4333796.zip", "mac": "https://dl.google.com/android/repository/commandlinetools-mac-6609375_latest.zip",
"mac_sha256": "ecb29358bc0f13d7c2fa0f9290135a5b608e38434aad9bf7067d0252c160853e" "mac_sha256": "2c3822db1c916655223e5ee8ce0fbf6b73d0b99012045c9dc8eaa6a5736c0c55"
}, },
"sdk_essential_packages": { "sdk_essential_packages": {
"default": ["platform-tools", "platforms;android-29"], "default": ["platform-tools", "platforms;android-29", "cmdline-tools;latest"],
"linux": [], "linux": [],
"mac": [], "mac": [],
"windows": ["extras;google;usb_driver"] "windows": ["extras;google;usb_driver"]

View File

@@ -130,6 +130,10 @@ void watcherDeleter(QFutureWatcher<void> *watcher)
delete watcher; delete watcher;
} }
static QString sdkRootArg(const AndroidConfig &config)
{
return "--sdk_root=" + config.sdkLocation().toString();
}
/*! /*!
Runs the \c sdkmanger tool with arguments \a args. Returns \c true if the command is Runs the \c sdkmanger tool with arguments \a args. Returns \c true if the command is
successfully executed. Output is copied into \a output. The function blocks the calling thread. successfully executed. Output is copied into \a output. The function blocks the calling thread.
@@ -137,13 +141,16 @@ void watcherDeleter(QFutureWatcher<void> *watcher)
static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &args, static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &args,
QString *output, int timeout = sdkManagerCmdTimeoutS) QString *output, int timeout = sdkManagerCmdTimeoutS)
{ {
QStringList newArgs = args;
newArgs.append(sdkRootArg(config));
qCDebug(sdkManagerLog) << "Running SDK Manager command (sync):" qCDebug(sdkManagerLog) << "Running SDK Manager command (sync):"
<< CommandLine(config.sdkManagerToolPath(), args).toUserOutput(); << CommandLine(config.sdkManagerToolPath(), newArgs)
.toUserOutput();
SynchronousProcess proc; SynchronousProcess proc;
proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(config)); proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(config));
proc.setTimeoutS(timeout); proc.setTimeoutS(timeout);
proc.setTimeOutMessageBoxEnabled(true); proc.setTimeOutMessageBoxEnabled(true);
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), args}); SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), newArgs});
if (output) if (output)
*output = response.allOutput(); *output = response.allOutput();
return response.result == SynchronousProcessResponse::Finished; return response.result == SynchronousProcessResponse::Finished;
@@ -160,8 +167,10 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
AndroidSdkManager::OperationOutput &output, double progressQuota, AndroidSdkManager::OperationOutput &output, double progressQuota,
bool interruptible = true, int timeout = sdkManagerOperationTimeoutS) bool interruptible = true, int timeout = sdkManagerOperationTimeoutS)
{ {
QStringList newArgs = args;
newArgs.append(sdkRootArg(config));
qCDebug(sdkManagerLog) << "Running SDK Manager command (async):" qCDebug(sdkManagerLog) << "Running SDK Manager command (async):"
<< CommandLine(config.sdkManagerToolPath(), args).toUserOutput(); << CommandLine(config.sdkManagerToolPath(), newArgs).toUserOutput();
int offset = fi.progressValue(); int offset = fi.progressValue();
SynchronousProcess proc; SynchronousProcess proc;
proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(config)); proc.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(config));
@@ -184,7 +193,7 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations, QObject::connect(&sdkManager, &AndroidSdkManager::cancelActiveOperations,
&proc, &SynchronousProcess::terminate); &proc, &SynchronousProcess::terminate);
} }
SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), args}); SynchronousProcessResponse response = proc.run({config.sdkManagerToolPath(), newArgs});
if (assertionFound) { if (assertionFound) {
output.success = false; output.success = false;
output.stdOutput = response.stdOut(); output.stdOutput = response.stdOut();
@@ -1011,7 +1020,7 @@ void AndroidSdkManagerPrivate::checkPendingLicense(SdkCmdFutureInterface &fi)
fi.setProgressValue(0); fi.setProgressValue(0);
AndroidSdkManager::OperationOutput result; AndroidSdkManager::OperationOutput result;
result.type = AndroidSdkManager::LicenseCheck; result.type = AndroidSdkManager::LicenseCheck;
QStringList args("--licenses"); const QStringList args = {"--licenses", sdkRootArg(m_config)};
if (!fi.isCanceled()) if (!fi.isCanceled())
sdkManagerCommand(m_config, args, m_sdkManager, fi, result, 100.0); sdkManagerCommand(m_config, args, m_sdkManager, fi, result, 100.0);
else else
@@ -1030,7 +1039,7 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdFutureInterface &fi)
QtcProcess licenseCommand; QtcProcess licenseCommand;
licenseCommand.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(m_config)); licenseCommand.setProcessEnvironment(AndroidConfigurations::toolsEnvironment(m_config));
bool reviewingLicenses = false; bool reviewingLicenses = false;
licenseCommand.setCommand(CommandLine(m_config.sdkManagerToolPath(), {"--licenses"})); licenseCommand.setCommand(CommandLine(m_config.sdkManagerToolPath(), {"--licenses", sdkRootArg(m_config)}));
if (Utils::HostOsInfo::isWindowsHost()) if (Utils::HostOsInfo::isWindowsHost())
licenseCommand.setUseCtrlCStub(true); licenseCommand.setUseCtrlCStub(true);
licenseCommand.start(); licenseCommand.start();

View File

@@ -313,7 +313,8 @@ void AndroidSdkModel::selectMissingEssentials()
} }
m_missingEssentials = pendingPkgs; m_missingEssentials = pendingPkgs;
qCDebug(androidSdkModelLog) << "Couldn't find some essential packages:" << m_missingEssentials; if (!m_missingEssentials.isEmpty())
qCDebug(androidSdkModelLog) << "Couldn't find some essential packages:" << m_missingEssentials;
} }
QList<const AndroidSdkPackage *> AndroidSdkModel::userSelection() const QList<const AndroidSdkPackage *> AndroidSdkModel::userSelection() const