summaryrefslogtreecommitdiff
path: root/src/androiddeployqt/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/androiddeployqt/main.cpp')
-rw-r--r--src/androiddeployqt/main.cpp117
1 files changed, 21 insertions, 96 deletions
diff --git a/src/androiddeployqt/main.cpp b/src/androiddeployqt/main.cpp
index 6a218b7af..8a8e59172 100644
--- a/src/androiddeployqt/main.cpp
+++ b/src/androiddeployqt/main.cpp
@@ -1,31 +1,26 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
@@ -100,8 +95,6 @@ struct Options
, generateAssetsFileList(true)
, build(true)
, gradle(false)
- , minimumAndroidVersion(9)
- , targetAndroidVersion(10)
, deploymentMechanism(Bundled)
, releasePackage(false)
, digestAlg(QLatin1String("SHA1"))
@@ -167,8 +160,6 @@ struct Options
QString ndkHost;
// Package information
- int minimumAndroidVersion;
- int targetAndroidVersion;
DeploymentMechanism deploymentMechanism;
QString packageName;
QStringList extraLibs;
@@ -920,7 +911,6 @@ void cleanAndroidFiles(const Options &options)
cleanTopFolders(options, options.androidSourceDirectory, options.outputDirectory);
cleanTopFolders(options, options.qtInstallDirectory + QLatin1String("/src/android/templates"), options.outputDirectory);
- cleanTopFolders(options, options.qtInstallDirectory + QLatin1String("/src/android/java"), options.outputDirectory + QLatin1String("__qt5__android__files__"));
}
bool copyAndroidTemplate(const Options &options, const QString &androidTemplate, const QString &outDirPrefix = QString())
@@ -969,8 +959,10 @@ bool copyAndroidTemplate(const Options &options)
if (!copyAndroidTemplate(options, QLatin1String("/src/android/templates")))
return false;
- return copyAndroidTemplate(options, QLatin1String("/src/android/java"),
- options.gradle ? QLatin1String("/__qt5__android__files__/") : QString());
+ if (options.gradle)
+ return true;
+
+ return copyAndroidTemplate(options, QLatin1String("/src/android/java"));
}
bool copyAndroidSources(const Options &options)
@@ -1344,10 +1336,10 @@ bool updateAndroidManifest(Options &options)
options.packageName = reader.attributes().value(QLatin1String("package")).toString();
} else if (reader.name() == QLatin1String("uses-sdk")) {
if (reader.attributes().hasAttribute(QLatin1String("android:minSdkVersion")))
- options.minimumAndroidVersion = reader.attributes().value(QLatin1String("android:minSdkVersion")).toInt();
-
- if (reader.attributes().hasAttribute(QLatin1String("android:targetSdkVersion")))
- options.targetAndroidVersion = reader.attributes().value(QLatin1String("android:targetSdkVersion")).toInt();
+ if (reader.attributes().value(QLatin1String("android:minSdkVersion")).toInt() < 16) {
+ fprintf(stderr, "Invalid minSdkVersion version, minSdkVersion must be >= 16\n");
+ return false;
+ }
} else if ((reader.name() == QLatin1String("application") ||
reader.name() == QLatin1String("activity")) &&
reader.attributes().hasAttribute(QLatin1String("android:label")) &&
@@ -1372,70 +1364,6 @@ bool updateAndroidManifest(Options &options)
return true;
}
-bool updateJavaFiles(const Options &options)
-{
- if (options.verbose)
- fprintf(stdout, " -- /src/org/qtproject/qt5/android/bindings/QtActivity.java\n");
-
-
- QString fileName(options.outputDirectory +
- (options.gradle ? QLatin1String("/__qt5__android__files__")
- : QString()) +
- QLatin1String("/src/org/qtproject/qt5/android/bindings/QtActivity.java"));
-
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly)) {
- fprintf(stderr, "Cannot open %s.\n", qPrintable(fileName));
- return false;
- }
-
- QByteArray contents;
-
- while (!file.atEnd()) {
- QByteArray line = file.readLine();
- if (line.startsWith("//@ANDROID-")) {
- bool ok;
- int requiredSdkVersion = line.mid(sizeof("//@ANDROID-") - 1).trimmed().toInt(&ok);
- if (requiredSdkVersion <= options.minimumAndroidVersion)
- contents += line;
-
- if (ok) {
- while (!file.atEnd()) {
- line = file.readLine();
- if (requiredSdkVersion <= options.minimumAndroidVersion)
- contents += line;
-
- if (line.startsWith(QByteArray("//@ANDROID-") + QByteArray::number(requiredSdkVersion)))
- break;
- }
-
- if (!line.startsWith(QByteArray("//@ANDROID-") + QByteArray::number(requiredSdkVersion))) {
- fprintf(stderr, "Mismatched tag ANDROID-%d in %s\n", requiredSdkVersion, qPrintable(fileName));
- return false;
- }
- } else {
- fprintf(stderr, "Warning: Misformatted tag in %s: %s\n", qPrintable(fileName), line.constData());
- }
- } else {
- contents += line;
- }
- }
-
- file.close();
-
- if (!file.open(QIODevice::WriteOnly)) {
- fprintf(stderr, "Can't open %s for writing.\n", qPrintable(fileName));
- return false;
- }
-
- if (file.write(contents) < contents.size()) {
- fprintf(stderr, "Failed to write contents to %s.\n", qPrintable(fileName));
- return false;
- }
-
- return true;
-}
-
bool updateAndroidFiles(Options &options)
{
if (options.verbose)
@@ -1447,9 +1375,6 @@ bool updateAndroidFiles(Options &options)
if (!updateAndroidManifest(options))
return false;
- if (!updateJavaFiles(options))
- return false;
-
return true;
}
@@ -2439,7 +2364,7 @@ bool buildGradleProject(const Options &options)
QString gradlePropertiesPath = options.outputDirectory + QLatin1String("gradle.properties");
GradleProperties gradleProperties = readGradleProperties(gradlePropertiesPath);
gradleProperties["buildDir"] = "build";
- gradleProperties["qt5AndroidDir"] = "__qt5__android__files__";
+ gradleProperties["qt5AndroidDir"] = (options.qtInstallDirectory + QLatin1String("/src/android/java")).toUtf8();
gradleProperties["androidCompileSdkVersion"] = options.androidPlatform.split(QLatin1Char('-')).last().toLocal8Bit();
if (gradleProperties["androidBuildToolsVersion"].isEmpty())
gradleProperties["androidBuildToolsVersion"] = options.sdkBuildToolsVersion.toLocal8Bit();