Android: Remove support old cmdline tools

Link: https://developer.android.com/studio/releases/sdk-tools

Change-Id: I9ea7c83af604bfc4b5d5e81b037034b7e148e99a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Artem Sokolovskii
2022-11-10 12:24:15 +01:00
parent e8454dc5fe
commit a130a7ae0b
5 changed files with 24 additions and 82 deletions

View File

@@ -487,20 +487,7 @@ bool AndroidBuildApkStep::init()
return false; return false;
} }
const QVersionNumber sdkToolsVersion = AndroidConfigurations::currentConfig().sdkToolsVersion(); if (version->qtVersion() < QVersionNumber(5, 4, 0)) {
if (sdkToolsVersion >= QVersionNumber(25, 3, 0)
&& AndroidConfigurations::currentConfig().preCmdlineSdkToolsInstalled()) {
if (!version->sourcePath().pathAppended("src/3rdparty/gradle").exists()) {
const QString error
= Tr::tr("The installed SDK tools version (%1) does not include Gradle "
"scripts. The minimum Qt version required for Gradle build to work "
"is %2")
.arg(sdkToolsVersion.toString())
.arg("5.9.0/5.6.3");
reportWarningOrError(error, Task::Error);
return false;
}
} else if (version->qtVersion() < QVersionNumber(5, 4, 0)) {
const QString error = Tr::tr("The minimum Qt version required for Gradle build to work is %1. " const QString error = Tr::tr("The minimum Qt version required for Gradle build to work is %1. "
"It is recommended to install the latest Qt version.") "It is recommended to install the latest Qt version.")
.arg("5.4.0"); .arg("5.4.0");

View File

@@ -451,21 +451,9 @@ QString AndroidConfig::apiLevelNameFor(const SdkPlatform *platform)
QString("android-%1").arg(platform->apiLevel()) : ""; QString("android-%1").arg(platform->apiLevel()) : "";
} }
// This is checking for the SDK tools [*] that were deprecated in favor of
// the command-line tools.
// See https://developer.android.com/studio/releases/sdk-tools
bool AndroidConfig::preCmdlineSdkToolsInstalled() const
{
QString toolPath("tools/bin/sdkmanager");
if (HostOsInfo::isWindowsHost())
toolPath += ANDROID_BAT_SUFFIX;
return m_sdkLocation.pathAppended(toolPath).exists();
}
FilePath AndroidConfig::adbToolPath() const FilePath AndroidConfig::adbToolPath() const
{ {
return m_sdkLocation / "platform-tools/adb" QTC_HOST_EXE_SUFFIX; return m_sdkLocation.pathAppended("platform-tools/adb").withExecutableSuffix();
} }
FilePath AndroidConfig::emulatorToolPath() const FilePath AndroidConfig::emulatorToolPath() const
@@ -475,52 +463,31 @@ FilePath AndroidConfig::emulatorToolPath() const
if (emulatorFile.exists()) if (emulatorFile.exists())
return emulatorFile; return emulatorFile;
return m_sdkLocation.pathAppended("tools/emulator").withExecutableSuffix(); return FilePath();
} }
FilePath AndroidConfig::sdkManagerToolPath() const FilePath AndroidConfig::sdkManagerToolPath() const
{ {
const QStringList sdkmanagerPaths = { const FilePath sdkmanagerPath = m_sdkLocation.pathAppended(Constants::cmdlineToolsName)
QString(Constants::cmdlineToolsName).append("/latest/bin/sdkmanager"), .pathAppended("latest/bin/sdkmanager" ANDROID_BAT_SUFFIX);
"tools/bin/sdkmanager"};
for (const QString &toolPath : sdkmanagerPaths) {
QString toolPathWithSuffix = toolPath;
if (HostOsInfo::isWindowsHost())
toolPathWithSuffix += ANDROID_BAT_SUFFIX;
const FilePath sdkmanagerPath = m_sdkLocation / toolPathWithSuffix;
if (sdkmanagerPath.exists()) if (sdkmanagerPath.exists())
return sdkmanagerPath; return sdkmanagerPath;
}
// If it's a first time install use the path of Constants::cmdlineToolsName temporary download // If it's a first time install use the path of Constants::cmdlineToolsName temporary download
const FilePath tmpSdkPath = m_temporarySdkToolsPath; const FilePath sdkmanagerTmpPath = m_temporarySdkToolsPath.pathAppended(
if (!tmpSdkPath.isEmpty()) { "/bin/sdkmanager" ANDROID_BAT_SUFFIX);
QString suffix = "bin/sdkmanager"; if (sdkmanagerTmpPath.exists())
if (HostOsInfo::isWindowsHost()) return sdkmanagerTmpPath;
suffix += ANDROID_BAT_SUFFIX;
const FilePath tmpsdkManagerPath = tmpSdkPath.pathAppended(suffix);
if (tmpsdkManagerPath.exists())
return tmpsdkManagerPath;
}
return FilePath(); return FilePath();
} }
FilePath AndroidConfig::avdManagerToolPath() const FilePath AndroidConfig::avdManagerToolPath() const
{ {
const QStringList sdkmanagerPaths = { const FilePath sdkmanagerPath = m_sdkLocation.pathAppended(Constants::cmdlineToolsName)
QString(Constants::cmdlineToolsName).append("/latest/bin/avdmanager"), .pathAppended("/latest/bin/avdmanager" ANDROID_BAT_SUFFIX);
"tools/bin/avdmanager"};
for (const QString &toolPath : sdkmanagerPaths) {
QString toolPathWithSuffix = toolPath;
if (HostOsInfo::isWindowsHost())
toolPathWithSuffix += ANDROID_BAT_SUFFIX;
const FilePath sdkmanagerPath = m_sdkLocation / toolPathWithSuffix;
if (sdkmanagerPath.exists()) if (sdkmanagerPath.exists())
return sdkmanagerPath; return sdkmanagerPath;
}
return FilePath(); return FilePath();
} }
@@ -532,23 +499,15 @@ void AndroidConfig::setTemporarySdkToolsPath(const Utils::FilePath &path)
FilePath AndroidConfig::sdkToolsVersionPath() const FilePath AndroidConfig::sdkToolsVersionPath() const
{ {
const QStringList sdkVersionPaths = { const FilePath sdkVersionPaths = m_sdkLocation.pathAppended(Constants::cmdlineToolsName)
QString(Constants::cmdlineToolsName).append("/latest/source.properties"), .pathAppended("/latest/source.properties");
"tools/source.properties"}; if (sdkVersionPaths.exists())
return sdkVersionPaths;
for (const QString &versionPath : sdkVersionPaths) {
const FilePath sdkVersionPath = m_sdkLocation / versionPath;
if (sdkVersionPath.exists())
return sdkVersionPath;
}
// If it's a first time install use the path of Constants::cmdlineToolsName temporary download // If it's a first time install use the path of Constants::cmdlineToolsName temporary download
const FilePath tmpSdkPath = m_temporarySdkToolsPath; const FilePath tmpSdkPath = m_temporarySdkToolsPath.pathAppended("source.properties");
if (!tmpSdkPath.isEmpty()) { if (tmpSdkPath.exists())
const FilePath sdkVersionPath = tmpSdkPath.pathAppended("source.properties"); return tmpSdkPath;
if (sdkVersionPath.exists())
return sdkVersionPath;
}
return FilePath(); return FilePath();
} }

View File

@@ -134,8 +134,6 @@ public:
QString getProductModel(const QString &device) const; QString getProductModel(const QString &device) const;
bool isConnected(const QString &serialNumber) const; bool isConnected(const QString &serialNumber) const;
bool preCmdlineSdkToolsInstalled() const;
bool sdkFullyConfigured() const { return m_sdkFullyConfigured; } bool sdkFullyConfigured() const { return m_sdkFullyConfigured; }
void setSdkFullyConfigured(bool allEssentialsInstalled) { m_sdkFullyConfigured = allEssentialsInstalled; } void setSdkFullyConfigured(bool allEssentialsInstalled) { m_sdkFullyConfigured = allEssentialsInstalled; }

View File

@@ -8,13 +8,11 @@
namespace Android { namespace Android {
namespace Internal { namespace Internal {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
#define ANDROID_BAT_SUFFIX ".bat" #define ANDROID_BAT_SUFFIX ".bat"
#else #else
#define ANDROID_BAT_SUFFIX "" #define ANDROID_BAT_SUFFIX ""
#endif #endif
} // namespace Internal } // namespace Internal
namespace Constants { namespace Constants {

View File

@@ -20,6 +20,7 @@
#include <utils/infolabel.h> #include <utils/infolabel.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
@@ -289,8 +290,7 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles()
if (m_copyGradle) { if (m_copyGradle) {
FilePath gradlePath = version->prefix() / "src/3rdparty/gradle"; FilePath gradlePath = version->prefix() / "src/3rdparty/gradle";
if (!gradlePath.exists()) QTC_ASSERT(gradlePath.exists(), return);
gradlePath = AndroidConfigurations::currentConfig().sdkLocation() / "tools/templates/gradle/wrapper";
FileUtils::copyRecursively(gradlePath, m_directory, nullptr, copy); FileUtils::copyRecursively(gradlePath, m_directory, nullptr, copy);
} }