diff options
author | Alexey Edelev <[email protected]> | 2024-11-06 16:08:29 +0100 |
---|---|---|
committer | Alexey Edelev <[email protected]> | 2025-07-07 17:07:23 +0200 |
commit | 6e4df829b648e8620d618f1be80985c6638d4e9e (patch) | |
tree | 432feb4764680f6a708bb06b69b38fe02122dba1 /src/android | |
parent | 118fa1952813d78707a16f7b9d95c2d72486f38a (diff) |
This approach is more flexible and modernizes the gradle project
structure for Qt apps. We now try to reproduce the CMake Android project
structure of user applications, in the modern Android project
structure described here: https://developer.android.com/build
The new structure using the module based application build and unlocks
the support for the use of dynamic features and Android libraries(aar).
All gradle-related rules are generated by CMake and androiddeployqt is
used in the auxiliary mode only(--aux-mode option). Update gradle
templates.
To opt-in the modern deployment use the QT_ANDROID_MODERN_BUNDLE
variable.
Task-number: QTBUG-116683
Task-number: QTBUG-124600
Change-Id: I343b884dea77a7b3b9059cf876a81c3693d0294b
Reviewed-by: Assam Boudjelthia <[email protected]>
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/android/REUSE.toml | 2 | ||||
-rw-r--r-- | src/android/templates_cmake/CMakeLists.txt | 24 | ||||
-rw-r--r-- | src/android/templates_cmake/build.gradle.in | 53 | ||||
-rw-r--r-- | src/android/templates_cmake/gradle.properties.in | 12 | ||||
-rw-r--r-- | src/android/templates_cmake/settings.gradle.in | 17 |
6 files changed, 108 insertions, 1 deletions
diff --git a/src/android/CMakeLists.txt b/src/android/CMakeLists.txt index 7c99ce7264e..12fbca624b3 100644 --- a/src/android/CMakeLists.txt +++ b/src/android/CMakeLists.txt @@ -9,6 +9,7 @@ if (ANDROID) add_subdirectory(java) add_subdirectory(templates) add_subdirectory(templates_aar) + add_subdirectory(templates_cmake) endif() qt_internal_add_java_documentation(Global) diff --git a/src/android/REUSE.toml b/src/android/REUSE.toml index 7d5a22fd2f7..6d821d52904 100644 --- a/src/android/REUSE.toml +++ b/src/android/REUSE.toml @@ -1,7 +1,7 @@ version = 1 [[annotations]] -path = ["jar/build.gradle", "jar/settings.gradle", "templates/build.gradle"] +path = ["jar/build.gradle", "jar/settings.gradle", "templates/build.gradle", "templates_cmake/**"] precedence = "closest" comment = "double check" SPDX-FileCopyrightText = "Copyright (C) 2024 The Qt Company Ltd." diff --git a/src/android/templates_cmake/CMakeLists.txt b/src/android/templates_cmake/CMakeLists.txt new file mode 100644 index 00000000000..253626e3b53 --- /dev/null +++ b/src/android/templates_cmake/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +set(templates_files + "${CMAKE_CURRENT_SOURCE_DIR}/settings.gradle.in" + "${CMAKE_CURRENT_SOURCE_DIR}/build.gradle.in" + "${CMAKE_CURRENT_SOURCE_DIR}/gradle.properties.in" +) + +add_custom_target(Qt6AndroidCMakeTemplates + SOURCES + ${templates_files} +) + +qt_path_join(destination ${QT_INSTALL_DIR} ${INSTALL_DATADIR} "src/android/templates_cmake") + +qt_copy_or_install(FILES ${templates_files} DESTINATION "${destination}") + +if(NOT QT_WILL_INSTALL) + qt_internal_copy_at_build_time(TARGET Qt6AndroidCMakeTemplates + FILES ${templates_files} + DESTINATION ${destination} + ) +endif() diff --git a/src/android/templates_cmake/build.gradle.in b/src/android/templates_cmake/build.gradle.in new file mode 100644 index 00000000000..a76172594bd --- /dev/null +++ b/src/android/templates_cmake/build.gradle.in @@ -0,0 +1,53 @@ +buildscript { + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:8.6.0' + } +} + +apply plugin: '@GRADLE_PLUGIN_TYPE@' + +dependencies { + @GRADLE_DEPENDENCIES@ +} + +android { + namespace '@PACKAGE_NAME@' + compileSdkVersion '@ANDROID_COMPILE_SDK_VERSION@' + buildToolsVersion '@ANDROID_BUILD_TOOLS_VERSION@' + ndkVersion '@ANDROID_NDK_REVISION@' + + defaultConfig { + @DEFAULT_CONFIG_VALUES@ + } + + sourceSets { + main { +@SOURCE_SETS@ + } + } + + tasks.withType(JavaCompile) { + options.incremental = true + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + lintOptions { + abortOnError false + } + + // Do not compress Qt binary resources file + aaptOptions { + noCompress 'rcc' + } + + @ANDROID_DEPLOYMENT_EXTRAS@ +} diff --git a/src/android/templates_cmake/gradle.properties.in b/src/android/templates_cmake/gradle.properties.in new file mode 100644 index 00000000000..b751946190a --- /dev/null +++ b/src/android/templates_cmake/gradle.properties.in @@ -0,0 +1,12 @@ +# Project-wide Gradle settings. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2500m -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# Enable building projects in parallel +org.gradle.parallel=true + +# Allow AndroidX usage +android.useAndroidX=true diff --git a/src/android/templates_cmake/settings.gradle.in b/src/android/templates_cmake/settings.gradle.in new file mode 100644 index 00000000000..4aca55ffd6d --- /dev/null +++ b/src/android/templates_cmake/settings.gradle.in @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "@ROOT_PROJECT_NAME@" +include(":app") |