Android: Bump gradle (plugin) versions

Move min & target sdk from AndroidManifest.xml to build.gradle

Fixes: QTBUG-70817
Change-Id: Id9bb9825a3232587e0255b2d3d6f0273c5f9b66a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
BogDan Vatra 2020-03-02 17:00:04 +02:00 committed by BogDan Vatra
parent 8131116896
commit 519ea72108
7 changed files with 38 additions and 4 deletions

View File

@ -43,6 +43,9 @@ isEmpty(ALL_ANDROID_ABIS): ALL_ANDROID_ABIS = arm64-v8a armeabi-v7a x86_64 x86
CONFIG += $$ANDROID_PLATFORM
ANDROID_MIN_SDK_VERSION = $$replace(ANDROID_PLATFORM, "android-", "")
ANDROID_TARGET_SDK_VERSION = 28
NDK_LLVM_PATH = $$NDK_ROOT/toolchains/llvm/prebuilt/$$NDK_HOST
QMAKE_CC = $$NDK_LLVM_PATH/bin/clang
QMAKE_CXX = $$NDK_LLVM_PATH/bin/clang++

View File

@ -53,6 +53,12 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-embedded {
!isEmpty(ANDROID_VERSION_CODE): \
FILE_CONTENT += " \"android-version-code\": $$emitString($$ANDROID_VERSION_CODE),"
!isEmpty(ANDROID_MIN_SDK_VERSION): \
FILE_CONTENT += " \"android-min-sdk-version\": $$emitString($$ANDROID_MIN_SDK_VERSION),"
!isEmpty(ANDROID_TARGET_SDK_VERSION): \
FILE_CONTENT += " \"android-target-sdk-version\": $$emitString($$ANDROID_TARGET_SDK_VERSION),"
!isEmpty(ANDROID_EXTRA_LIBS): \
FILE_CONTENT += " \"android-extra-libs\": $$emitString($$join(ANDROID_EXTRA_LIBS, ",")),"

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,7 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="-- %%INSERT_VERSION_NAME%% --" android:versionCode="-- %%INSERT_VERSION_CODE%% --" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<!-- %%INSERT_PERMISSIONS -->

View File

@ -5,7 +5,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
@ -59,4 +59,10 @@ android {
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
resConfig "en"
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
}
}

View File

@ -18,6 +18,8 @@ if (NOT ${PROJECT_NAME}-MultiAbiBuild)
option(ANDROID_BUILD_ABI_${abi} "Enable the build for Android ${abi}" ${abi_initial_value})
endif()
endforeach()
option(ANDROID_MIN_SDK_VERSION "Android minimum SDK version" "21")
option(ANDROID_TARGET_SDK_VERSION "Android target SDK version" "28")
# Make sure to delete the "android-build" directory, which contains all the
# build artefacts, and also the androiddeployqt/gradle artefacts
@ -101,6 +103,9 @@ if (NOT ${PROJECT_NAME}-MultiAbiBuild)
generate_json_variable(ANDROID_VERSION_NAME "android-version-name")
generate_json_variable_list(ANDROID_EXTRA_LIBS "android-extra-libs")
generate_json_variable_list(QML_IMPORT_PATH "qml-import-paths")
generate_json_variable_list(ANDROID_MIN_SDK_VERSION "android-min-sdk-version")
generate_json_variable_list(ANDROID_TARGET_SDK_VERSION "android-target-sdk-version")
configure_file(
"${CMAKE_BINARY_DIR}/android_deployment_settings.json.in"

View File

@ -169,6 +169,8 @@ struct Options
// Versioning
QString versionName;
QString versionCode;
QByteArray minSdkVersion{"21"};
QByteArray targetSdkVersion{"28"};
// lib c++ path
QString stdCppPath;
@ -849,6 +851,18 @@ bool readInputFile(Options *options)
options->versionCode = QStringLiteral("1");
}
{
const QJsonValue ver = jsonObject.value(QLatin1String("android-min-sdk-version"));
if (!ver.isUndefined())
options->minSdkVersion = ver.toString().toUtf8();
}
{
const QJsonValue ver = jsonObject.value(QLatin1String("android-target-sdk-version"));
if (!ver.isUndefined())
options->targetSdkVersion = ver.toString().toUtf8();
}
{
const QJsonObject targetArchitectures = jsonObject.value(QLatin1String("architectures")).toObject();
if (targetArchitectures.isEmpty()) {
@ -2298,6 +2312,8 @@ bool buildAndroidProject(const Options &options)
gradleProperties["buildDir"] = "build";
gradleProperties["qt5AndroidDir"] = (options.qtInstallDirectory + QLatin1String("/src/android/java")).toUtf8();
gradleProperties["androidCompileSdkVersion"] = options.androidPlatform.split(QLatin1Char('-')).last().toLocal8Bit();
gradleProperties["qtMinSdkVersion"] = options.minSdkVersion;
gradleProperties["qtTargetSdkVersion"] = options.targetSdkVersion;
if (gradleProperties["androidBuildToolsVersion"].isEmpty())
gradleProperties["androidBuildToolsVersion"] = options.sdkBuildToolsVersion.toLocal8Bit();