Commit 09f20adc authored by Daniel Teske's avatar Daniel Teske

Android: Only show android sdk versions that are supported by qt

That is at least android-9 for qt 5.

Task-number: QTCREATORBUG-9067
Change-Id: I977f8a35e5d2db2c645fe1a1bc52ef5d7b9f8b35
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
parent a019c4c7
......@@ -235,17 +235,22 @@ bool AndroidManager::ensureIconAttribute(ProjectExplorer::Target *target)
QString AndroidManager::targetSDK(ProjectExplorer::Target *target)
{
QString fallback = QLatin1String("android-8");
if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target->kit()))
if (qt->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0))
fallback = QLatin1String("android-9");
if (!createAndroidTemplatesIfNecessary(target))
return AndroidConfigurations::instance().bestMatch(QLatin1String("android-8"));
return AndroidConfigurations::instance().bestMatch(fallback);
QFile file(defaultPropertiesPath(target).toString());
if (!file.open(QIODevice::ReadOnly))
return AndroidConfigurations::instance().bestMatch(QLatin1String("android-8"));
return AndroidConfigurations::instance().bestMatch(fallback);
while (!file.atEnd()) {
QByteArray line = file.readLine();
if (line.startsWith("target="))
return QString::fromLatin1(line.trimmed().mid(7));
}
return AndroidConfigurations::instance().bestMatch(QLatin1String("android-8"));
return AndroidConfigurations::instance().bestMatch(fallback);
}
bool AndroidManager::setTargetSDK(ProjectExplorer::Target *target, const QString &sdk)
......@@ -534,12 +539,18 @@ bool AndroidManager::createAndroidTemplatesIfNecessary(ProjectExplorer::Target *
if (!androidFiles.isEmpty())
qt4Project->rootProjectNode()->addFiles(ProjectExplorer::UnknownFileType, androidFiles);
QStringList sdks = AndroidConfigurations::instance().sdkTargets();
int minApiLevel = 4;
if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target->kit()))
if (qt->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0))
minApiLevel = 9;
QStringList sdks = AndroidConfigurations::instance().sdkTargets(minApiLevel);
if (sdks.isEmpty()) {
raiseError(tr("No Qt for Android SDKs were found.\nPlease install at least one SDK."));
return false;
}
updateTarget(target, AndroidConfigurations::instance().sdkTargets().at(0));
updateTarget(target, AndroidConfigurations::instance().sdkTargets(minApiLevel).at(0));
QStringList apps = availableTargetApplications(target);
if (!apps.isEmpty())
setTargetApplication(target, apps.at(0));
......
......@@ -50,6 +50,8 @@
#include <QFileDialog>
#include <QFileSystemWatcher>
#include <QMessageBox>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
namespace Android {
namespace Internal {
......@@ -278,7 +280,13 @@ void AndroidPackageCreationWidget::updateAndroidProjectInfo()
ProjectExplorer::Target *target = m_step->target();
const QString packageName = AndroidManager::packageName(target);
m_ui->targetSDKComboBox->clear();
QStringList targets = AndroidConfigurations::instance().sdkTargets();
int minApiLevel = 4;
if (QtSupport::BaseQtVersion *qt = QtSupport::QtKitInformation::qtVersion(target->kit()))
if (qt->qtVersion() >= QtSupport::QtVersionNumber(5, 0, 0))
minApiLevel = 9;
QStringList targets = AndroidConfigurations::instance().sdkTargets(minApiLevel);
m_ui->targetSDKComboBox->addItems(targets);
m_ui->targetSDKComboBox->setCurrentIndex(targets.indexOf(AndroidManager::targetSDK(target)));
m_ui->packageNameLineEdit->setText(packageName);
......
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