From 3e2e6cb487370ae0c80f554f2a77e8e2ace21734 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Fri, 4 Jul 2025 23:36:34 +0200 Subject: [PATCH] [android] Fix gradle deprecations Signed-off-by: Alexander Borsuk --- android/app/build.gradle | 37 +++++++++++++++++++------------------ android/build.gradle | 12 +++++------- android/sdk/build.gradle | 12 ++++++------ android/settings.gradle | 2 +- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 1e9c4e803..f681ad917 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -37,10 +37,10 @@ project.ext.appName = 'CoMaps' //} android { - namespace 'app.organicmaps' + namespace = 'app.organicmaps' // TODO: it should not be here, but in sdk/build.gradle. But for some reason it should be specified here as well. - ndkVersion '28.2.13676358' + ndkVersion = '28.2.13676358' dependenciesInfo { // Disables dependency metadata when building APKs (for IzzyOnDroid/F-Droid) @@ -62,21 +62,21 @@ android { } // All properties are read from gradle.properties file - compileSdk propCompileSdkVersion.toInteger() + compileSdk = propCompileSdkVersion.toInteger() defaultConfig { versionCode = rootProject.ext.versionCode versionName = rootProject.ext.versionName println('Version: ' + versionName) println('VersionCode: ' + versionCode) - minSdk propMinSdkVersion.toInteger() - targetSdk propTargetSdkVersion.toInteger() + minSdk = propMinSdkVersion.toInteger() + targetSdk = propTargetSdkVersion.toInteger() applicationId project.ext.appId buildConfigField 'String', 'SUPPORT_MAIL', '"android@comaps.app"' // Should be customized in flavors. buildConfigField 'String', 'REVIEW_URL', '""' - setProperty('archivesBaseName', appName.replaceAll('\\s','') + '-' + defaultConfig.versionCode) + base.archivesName = appName.replaceAll('\\s','') + '-' + defaultConfig.versionCode ndk.debugSymbolLevel = 'full' } @@ -128,10 +128,10 @@ android { splits.abi { boolean enabled = project.hasProperty('splitApk') println ('Create separate apks: ' + enabled) - enable enabled + enable = enabled reset() include 'x86', 'armeabi-v7a', 'arm64-v8a', 'x86_64' - universalApk true + universalApk = true } lint { @@ -144,7 +144,7 @@ android { disable 'CustomSplashScreen' // https://github.com/organicmaps/organicmaps/issues/3610 disable 'InsecureBaseConfiguration' - abortOnError true + abortOnError = true } gradle.projectsEvaluated { @@ -204,7 +204,7 @@ android { applicationIdSuffix '.debug' // Allows to install debug and release builds together versionNameSuffix '-debug' zipAlignEnabled true - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug resValue 'string', 'app_name', 'CoMaps Debug' } @@ -212,15 +212,16 @@ android { if (taskName.contains('release')) { if (secureReleasePropertiesFileExists) { println('Using RELEASE signing keys from secure.properties.release') - signingConfig signingConfigs.release + signingConfig = signingConfigs.release } else { println('NO RELEASE signing keys found') println('Using DEBUG signing keys') - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } + minifyEnabled true - shrinkResources true + shrinkResources = true // Includes the default ProGuard rules files that are packaged with the Android Gradle plugin. // To learn more, go to the documentation section about R8 configuration files. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' @@ -233,15 +234,15 @@ android { if (taskName.contains('beta')) { if (secureTestPropertiesFileExists) { println('Using TEST signing keys from secure.properties.test') - signingConfig signingConfigs.test + signingConfig = signingConfigs.test } else { println('NO TEST signing keys found') println('Using DEBUG signing keys') - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } minifyEnabled true - shrinkResources true + shrinkResources = true // Includes the default ProGuard rules files that are packaged with the Android Gradle plugin. // To learn more, go to the documentation section about R8 configuration files. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' @@ -253,7 +254,7 @@ android { // We don't compress these extensions in assets/ because our random FileReader can't read zip-compressed files from apk. // TODO: Load all minor files via separate call to ReadAsString which can correctly handle compressed files in zip containers. androidResources { - ignoreAssetsPattern '!.svn:!.git:!.DS_Store:!*.scc:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*~' + ignoreAssetsPattern = '!.svn:!.git:!.DS_Store:!*.scc:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*~' noCompress = ['txt', 'bin', 'html', 'png', 'json', 'mwm', 'ttf', 'sdf', 'ui', 'config', 'csv', 'spv', 'obj'] localeFilters += [ "af", @@ -310,7 +311,7 @@ android { } compileOptions { - coreLibraryDesugaringEnabled true + coreLibraryDesugaringEnabled = true sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 diff --git a/android/build.gradle b/android/build.gradle index a4cedcf15..7f3e4dfc4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -7,19 +7,17 @@ plugins { } def run(cmd) { - def stdout = new ByteArrayOutputStream() - exec { - commandLine = cmd - standardOutput = stdout + def output = providers.exec { + commandLine = cmd } - return stdout.toString() + return output.standardOutput.asText.get().trim() } def getVersion() { def isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows() def bash = isWindows ? 'C:\\Program Files\\Git\\bin\\bash.exe' : 'bash' - def versionCode = Integer.parseInt(run([bash, '../tools/unix/version.sh', 'android_code']).trim()) - def versionName = run([bash, '../tools/unix/version.sh', 'android_name']).trim() + def versionCode = Integer.parseInt(run([bash, '../tools/unix/version.sh', 'android_code'])) + def versionName = run([bash, '../tools/unix/version.sh', 'android_name']) return new Tuple2(versionCode, versionName) } diff --git a/android/sdk/build.gradle b/android/sdk/build.gradle index 47873a40c..1d3d4bdea 100644 --- a/android/sdk/build.gradle +++ b/android/sdk/build.gradle @@ -3,15 +3,15 @@ plugins { } android { - namespace 'app.organicmaps.sdk' - compileSdk propCompileSdkVersion.toInteger() + namespace = 'app.organicmaps.sdk' + compileSdk = propCompileSdkVersion.toInteger() - ndkVersion '28.2.13676358' + ndkVersion = '28.2.13676358' defaultConfig { - minSdk propMinSdkVersion.toInteger() - targetSdk propTargetSdkVersion.toInteger() + minSdk = propMinSdkVersion.toInteger() + targetSdk = propTargetSdkVersion.toInteger() externalNativeBuild { def pchFlag = 'OFF' @@ -85,7 +85,7 @@ android { externalNativeBuild { cmake { - version '3.22.1+' + version = '3.22.1+' buildStagingDirectory './nativeOutputs' path '../../CMakeLists.txt' } diff --git a/android/settings.gradle b/android/settings.gradle index 35da8e37d..0fae32e6b 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -10,7 +10,7 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://www.jitpack.io' } // MPAndroidChart + maven { url = 'https://www.jitpack.io' } // MPAndroidChart } } rootProject.name = 'CoMaps'