Commit 8dc98995 authored by Vikas Pachdha's avatar Vikas Pachdha
Browse files

Android: Force Gradle build post SDK tools version 25.3.0



Task-number: QTCREATORBUG-18013
Change-Id: Ic912427783d079f5f6bf06e3bf9a44657d24a96f
Reviewed-by: Riitta-Leena Miettinen's avatarLeena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: default avatarBogDan Vatra <bogdan@kdab.com>
parent 70be880b
......@@ -60,6 +60,8 @@
namespace Android {
using namespace Internal;
const QVersionNumber gradleScriptRevokedSdkVersion(25, 3, 0);
const QVersionNumber gradleScriptsContainedQtVersion(5, 9, 0);
const QLatin1String DeployActionKey("Qt4ProjectManager.AndroidDeployQtStep.DeployQtAction");
const QLatin1String KeystoreLocationKey("KeystoreLocation");
const QLatin1String BuildTargetSdkKey("BuildTargetSdk");
......@@ -140,6 +142,15 @@ bool AndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps)
if (!version)
return false;
if (AndroidConfigurations::currentConfig().sdkToolsVersion() >= gradleScriptRevokedSdkVersion &&
QVersionNumber::fromString(version->qtVersionString()) < gradleScriptsContainedQtVersion) {
emit addOutput(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(gradleScriptRevokedSdkVersion.toString())
.arg(gradleScriptsContainedQtVersion.toString()), OutputFormat::Stderr);
return false;
}
int minSDKForKit = AndroidManager::minimumSDK(target()->kit());
if (AndroidManager::minimumSDK(target()) < minSDKForKit) {
emit addOutput(tr("The API level set for the APK is less than the minimum required by the kit."
......
......@@ -102,7 +102,7 @@ protected:
AndroidDeployAction m_deployAction = BundleLibrariesDeployment;
bool m_signPackage = false;
bool m_verbose = false;
bool m_useGradle = false;
bool m_useGradle = true; // Ant builds are deprecated.
bool m_openPackageLocation = false;
bool m_openPackageLocationForRun = false;
bool m_addDebugger = true;
......
......@@ -54,9 +54,12 @@ AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step)
{
m_ui->setupUi(this);
m_ui->deprecatedInfoIconLabel->setPixmap(Utils::Icons::INFO.pixmap());
// Target sdk combobox
int minApiLevel = 9;
QStringList targets = AndroidConfig::apiLevelNamesFor(AndroidConfigurations::currentConfig().sdkTargets(minApiLevel));
const AndroidConfig &config = AndroidConfigurations::currentConfig();
QStringList targets = AndroidConfig::apiLevelNamesFor(config.sdkTargets(minApiLevel));
targets.removeDuplicates();
m_ui->targetSDKComboBox->addItems(targets);
m_ui->targetSDKComboBox->setCurrentIndex(targets.indexOf(AndroidManager::buildTargetSDK(step->target())));
......@@ -91,7 +94,9 @@ AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step)
m_ui->signingDebugDeployErrorIcon->setPixmap(Utils::Icons::CRITICAL.pixmap());
signPackageCheckBoxToggled(m_step->signPackage());
m_ui->useGradleCheckBox->setChecked(m_step->useGradle());
m_ui->useGradleCheckBox->setEnabled(config.antScriptsAvailable());
m_ui->useGradleCheckBox->setChecked(!config.antScriptsAvailable() ||
m_step->useGradle());
m_ui->verboseOutputCheckBox->setChecked(m_step->verboseOutput());
m_ui->openPackageLocationCheckBox->setChecked(m_step->openPackageLocation());
m_ui->addDebuggerCheckBox->setChecked(m_step->addDebugger());
......
......@@ -176,28 +176,66 @@ Deploying local Qt libraries is incompatible with Android 5.</string>
<string>Advanced Actions</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QCheckBox" name="verboseOutputCheckBox">
<item row="0" column="0">
<widget class="QCheckBox" name="useGradleCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Verbose output</string>
<string>Use Gradle (Ant builds are deprecated)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="1">
<widget class="QLabel" name="deprecatedInfoIconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Gradle builds are forced from Android SDK tools version 25.3.0 onwards as Ant scripts are no longer available.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="openPackageLocationCheckBox">
<property name="text">
<string>Open package location after build</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="useGradleCheckBox">
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="verboseOutputCheckBox">
<property name="text">
<string>Use Gradle</string>
<string>Verbose output</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="addDebuggerCheckBox">
<property name="enabled">
<bool>false</bool>
......
......@@ -76,6 +76,9 @@ namespace Android {
using namespace Internal;
namespace {
const QVersionNumber sdkToolsAntMissingVersion(25, 3, 0);
const QLatin1String SettingsGroup("AndroidConfigurations");
const QLatin1String SDKLocationKey("SDKLocation");
const QLatin1String NDKLocationKey("NDKLocation");
......@@ -823,9 +826,18 @@ void AndroidConfig::setAutomaticKitCreation(bool b)
m_automaticKitCreation = b;
}
bool AndroidConfig::antScriptsAvailable() const
{
return sdkToolsVersion() < sdkToolsAntMissingVersion;
}
bool AndroidConfig::useGrandle() const
{
return m_useGradle;
if (antScriptsAvailable()) {
return m_useGradle;
}
// Force gradle builds.
return true;
}
void AndroidConfig::setUseGradle(bool b)
......
......@@ -135,6 +135,8 @@ public:
bool automaticKitCreation() const;
void setAutomaticKitCreation(bool b);
bool antScriptsAvailable() const;
bool useGrandle() const;
void setUseGradle(bool b);
......@@ -205,7 +207,7 @@ private:
QStringList m_makeExtraSearchDirectories;
unsigned m_partitionSize = 1024;
bool m_automaticKitCreation = true;
bool m_useGradle = false;
bool m_useGradle = true; // Ant builds are deprecated.
//caches
mutable bool m_availableSdkPlatformsUpToDate = false;
......
......@@ -134,6 +134,8 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent)
{
m_ui->setupUi(this);
m_ui->deprecatedInfoIconLabel->setPixmap(Utils::Icons::INFO.pixmap());
connect(&m_checkGdbWatcher, &QFutureWatcherBase::finished,
this, &AndroidSettingsWidget::checkGdbFinished);
......@@ -160,7 +162,8 @@ AndroidSettingsWidget::AndroidSettingsWidget(QWidget *parent)
m_ui->AntLocationPathChooser->setPromptDialogTitle(tr("Select ant Script"));
m_ui->AntLocationPathChooser->setInitialBrowsePathBackup(dir);
m_ui->AntLocationPathChooser->setPromptDialogFilter(filter);
m_ui->UseGradleCheckBox->setChecked(m_androidConfig.useGrandle());
updateGradleBuildUi();
m_ui->OpenJDKLocationPathChooser->setFileName(m_androidConfig.openJDKLocation());
m_ui->OpenJDKLocationPathChooser->setPromptDialogTitle(tr("Select JDK Path"));
......@@ -478,6 +481,13 @@ void AndroidSettingsWidget::updateAvds()
enableAvdControls();
}
void AndroidSettingsWidget::updateGradleBuildUi()
{
m_ui->UseGradleCheckBox->setEnabled(m_androidConfig.antScriptsAvailable());
m_ui->UseGradleCheckBox->setChecked(!m_androidConfig.antScriptsAvailable() ||
m_androidConfig.useGrandle());
}
bool AndroidSettingsWidget::sdkLocationIsValid() const
{
Utils::FileName androidExe = m_androidConfig.sdkLocation();
......@@ -507,6 +517,7 @@ void AndroidSettingsWidget::saveSettings()
void AndroidSettingsWidget::sdkLocationEditingFinished()
{
m_androidConfig.setSdkLocation(Utils::FileName::fromUserInput(m_ui->SDKLocationPathChooser->rawPath()));
updateGradleBuildUi();
check(Sdk);
......
......@@ -95,6 +95,7 @@ private:
void checkGdbFinished();
void showGdbWarningDialog();
void updateAvds();
void updateGradleBuildUi();
private:
enum Mode { Sdk = 1, Ndk = 2, Java = 4, All = Sdk | Ndk | Java };
......
......@@ -237,20 +237,30 @@
</layout>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="CreateKitCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Automatically create kits for Android tool chains</string>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="spacing">
<number>2</number>
</property>
<property name="checked">
<bool>true</bool>
<property name="leftMargin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QCheckBox" name="CreateKitCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Automatically create kits for Android tool chains</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
......@@ -289,17 +299,59 @@
</layout>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="UseGradleCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
<number>4</number>
</property>
<property name="text">
<string>Use Gradle instead of Ant</string>
<property name="leftMargin">
<number>0</number>
</property>
</widget>
<item>
<widget class="QCheckBox" name="UseGradleCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use Gradle instead of Ant (Ant builds are deprecated)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deprecatedInfoIconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Gradle builds are forced from Android SDK tools version 25.3.0 onwards as Ant scripts are no longer available.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="11" column="0">
<widget class="QLabel" name="AntLocationLabel">
......
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