Commit c1b2ed03 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Android: More accurate Android Sdk location error messages



If the user installs a fresh Android SDK and selects its path in
the Android options, Qt Creator will still say that this is not
a valid Android SDK.

The reason is that Qt Creator also checks for the platform tools
to be installed. Installing those is a separate step which needs
to be done after installing the SDK.

This patch enables Qt Creator to tell the user if the platform
tools are missing, but the SDK is otherwise fine.

Change-Id: I3557fb93d46e8677498843250302d12c8babb1df
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@digia.com>
parent c3754368
......@@ -155,21 +155,11 @@ void AndroidSettingsWidget::check(AndroidSettingsWidget::Mode mode)
{
if (mode & Sdk) {
m_sdkState = Okay;
if (m_androidConfig.sdkLocation().isEmpty()) {
if (m_androidConfig.sdkLocation().isEmpty())
m_sdkState = NotSet;
} else {
Utils::FileName adb = m_androidConfig.sdkLocation();
Utils::FileName androidExe = m_androidConfig.sdkLocation();
Utils::FileName androidBat = m_androidConfig.sdkLocation();
Utils::FileName emulator = m_androidConfig.sdkLocation();
if (!adb.appendPath(QLatin1String("platform-tools/adb" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists()
|| (!androidExe.appendPath(QLatin1String("/tools/android" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists()
&& !androidBat.appendPath(QLatin1String("/tools/android" ANDROID_BAT_SUFFIX)).toFileInfo().exists())
|| !emulator.appendPath(QLatin1String("/tools/emulator" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists()) {
else if (!(sdkLocationIsValid() && sdkPlatformToolsInstalled()))
m_sdkState = Error;
}
}
}
if (mode & Ndk) {
m_ndkState = Okay;
......@@ -241,6 +231,9 @@ void AndroidSettingsWidget::applyToUi(AndroidSettingsWidget::Mode mode)
m_ui->sdkWarningIconLabel->setVisible(true);
m_ui->sdkWarningLabel->setVisible(true);
Utils::FileName location = Utils::FileName::fromUserInput(m_ui->SDKLocationLineEdit->text());
if (sdkLocationIsValid())
m_ui->sdkWarningLabel->setText(tr("The Platform tools are missing. Please use the Android SDK Manager to install them."));
else
m_ui->sdkWarningLabel->setText(tr("\"%1\" does not seem to be an Android SDK top folder.").arg(location.toUserOutput()));
} else {
m_ui->sdkWarningIconLabel->setVisible(false);
......@@ -300,6 +293,22 @@ void AndroidSettingsWidget::applyToUi(AndroidSettingsWidget::Mode mode)
}
}
bool AndroidSettingsWidget::sdkLocationIsValid() const
{
Utils::FileName androidExe = m_androidConfig.sdkLocation();
Utils::FileName androidBat = m_androidConfig.sdkLocation();
Utils::FileName emulator = m_androidConfig.sdkLocation();
return (androidExe.appendPath(QLatin1String("/tools/android" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists()
|| androidBat.appendPath(QLatin1String("/tools/android" ANDROID_BAT_SUFFIX)).toFileInfo().exists())
&& emulator.appendPath(QLatin1String("/tools/emulator" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists();
}
bool AndroidSettingsWidget::sdkPlatformToolsInstalled() const
{
Utils::FileName adb = m_androidConfig.sdkLocation();
return adb.appendPath(QLatin1String("platform-tools/adb" QTC_HOST_EXE_SUFFIX)).toFileInfo().exists();
}
void AndroidSettingsWidget::saveSettings()
{
sdkLocationEditingFinished();
......
......@@ -98,6 +98,8 @@ private:
enum State { NotSet = 0, Okay = 1, Error = 2 };
void check(Mode mode);
void applyToUi(Mode mode);
bool sdkLocationIsValid() const;
bool sdkPlatformToolsInstalled() const;
State m_sdkState;
State m_ndkState;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment