Commit 721d6546 authored by Daniel Teske's avatar Daniel Teske

Android: android.bat needs a special environment

See the below task for details:

Task-number: QTCREATORBUG-10575
Change-Id: I7756d8780b33ede4c3d4eac7e281c9eabfa47e35
Reviewed-by: default avatarRobert Loehning <robert.loehning@digia.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent c9c0f801
......@@ -248,6 +248,7 @@ void AndroidConfigurations::updateAvailableSdkPlatforms()
m_availableSdkPlatforms.clear();
QProcess proc;
proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
proc.start(androidToolPath().toString(), QStringList() << QLatin1String("list") << QLatin1String("target")); // list avaialbe AVDs
if (!proc.waitForFinished(-1)) {
proc.terminate();
......@@ -283,6 +284,14 @@ FileName AndroidConfigurations::adbToolPath() const
return path.appendPath(QLatin1String("platform-tools/adb" QTC_HOST_EXE_SUFFIX));
}
Utils::Environment AndroidConfigurations::androidToolEnvironment() const
{
Utils::Environment env = Utils::Environment::systemEnvironment();
if (!m_config.openJDKLocation.isEmpty())
env.set(QLatin1String("JAVA_HOME"), m_config.openJDKLocation.toUserOutput());
return env;
}
FileName AndroidConfigurations::androidToolPath() const
{
if (HostOsInfo::isWindowsHost()) {
......@@ -524,6 +533,7 @@ QString AndroidConfigurations::createAVD(int minApiLevel, QString targetArch) co
QString AndroidConfigurations::createAVD(const QString &target, const QString &name, const QString &abi, int sdcardSize ) const
{
QProcess proc;
proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
proc.start(androidToolPath().toString(),
QStringList() << QLatin1String("create") << QLatin1String("avd")
<< QLatin1String("-t") << target
......@@ -565,6 +575,7 @@ QString AndroidConfigurations::createAVD(const QString &target, const QString &n
bool AndroidConfigurations::removeAVD(const QString &name) const
{
QProcess proc;
proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
proc.start(androidToolPath().toString(),
QStringList() << QLatin1String("delete") << QLatin1String("avd")
<< QLatin1String("-n") << name);
......@@ -579,6 +590,7 @@ QVector<AndroidDeviceInfo> AndroidConfigurations::androidVirtualDevices() const
{
QVector<AndroidDeviceInfo> devices;
QProcess proc;
proc.setProcessEnvironment(androidToolEnvironment().toProcessEnvironment());
proc.start(androidToolPath().toString(),
QStringList() << QLatin1String("list") << QLatin1String("avd")); // list available AVDs
if (!proc.waitForFinished(-1)) {
......
......@@ -38,6 +38,7 @@
#include <QMap>
#include <projectexplorer/abi.h>
#include <utils/fileutils.h>
#include <utils/environment.h>
QT_BEGIN_NAMESPACE
class QSettings;
......@@ -89,6 +90,7 @@ public:
QStringList sdkTargets(int minApiLevel = 0) const;
Utils::FileName adbToolPath() const;
Utils::FileName androidToolPath() const;
Utils::Environment androidToolEnvironment() const;
Utils::FileName antToolPath() const;
Utils::FileName emulatorToolPath() const;
Utils::FileName gccPath(ProjectExplorer::Abi::Architecture architecture, const QString &ndkToolChainVersion) const;
......
......@@ -706,6 +706,7 @@ void AndroidManager::updateTarget(ProjectExplorer::Target *target, const QString
params << QLatin1String("-t") << targetSDK;
if (!name.isEmpty())
params << QLatin1String("-n") << name;
androidProc.setProcessEnvironment(AndroidConfigurations::instance().androidToolEnvironment().toProcessEnvironment());
androidProc.start(AndroidConfigurations::instance().androidToolPath().toString(), params);
if (!androidProc.waitForFinished(-1))
androidProc.terminate();
......
......@@ -35,6 +35,10 @@
#include "androidconstants.h"
#include "androidtoolchain.h"
#ifdef Q_OS_WIN
#include <utils/winutils.h>
#endif
#include <utils/environment.h>
#include <utils/hostosinfo.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/kitmanager.h>
......@@ -434,8 +438,12 @@ void AndroidSettingsWidget::manageAVD()
QProcess *avdProcess = new QProcess();
connect(this, SIGNAL(destroyed()), avdProcess, SLOT(deleteLater()));
connect(avdProcess, SIGNAL(finished(int)), avdProcess, SLOT(deleteLater()));
avdProcess->start(AndroidConfigurations::instance().androidToolPath().toString(),
QStringList() << QLatin1String("avd"));
avdProcess->setProcessEnvironment(AndroidConfigurations::instance().androidToolEnvironment().toProcessEnvironment());
QString executable = AndroidConfigurations::instance().androidToolPath().toString();
QStringList arguments = QStringList() << QLatin1String("avd");
avdProcess->start(executable, arguments);
}
......
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