[android] Fix gradle deprecations

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-07-04 23:36:34 +02:00
committed by Konstantin Pastbin
parent 21020429cb
commit 3e2e6cb487
4 changed files with 31 additions and 32 deletions

View File

@@ -37,10 +37,10 @@ project.ext.appName = 'CoMaps'
//} //}
android { 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. // 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 { dependenciesInfo {
// Disables dependency metadata when building APKs (for IzzyOnDroid/F-Droid) // Disables dependency metadata when building APKs (for IzzyOnDroid/F-Droid)
@@ -62,21 +62,21 @@ android {
} }
// All properties are read from gradle.properties file // All properties are read from gradle.properties file
compileSdk propCompileSdkVersion.toInteger() compileSdk = propCompileSdkVersion.toInteger()
defaultConfig { defaultConfig {
versionCode = rootProject.ext.versionCode versionCode = rootProject.ext.versionCode
versionName = rootProject.ext.versionName versionName = rootProject.ext.versionName
println('Version: ' + versionName) println('Version: ' + versionName)
println('VersionCode: ' + versionCode) println('VersionCode: ' + versionCode)
minSdk propMinSdkVersion.toInteger() minSdk = propMinSdkVersion.toInteger()
targetSdk propTargetSdkVersion.toInteger() targetSdk = propTargetSdkVersion.toInteger()
applicationId project.ext.appId applicationId project.ext.appId
buildConfigField 'String', 'SUPPORT_MAIL', '"android@comaps.app"' buildConfigField 'String', 'SUPPORT_MAIL', '"android@comaps.app"'
// Should be customized in flavors. // Should be customized in flavors.
buildConfigField 'String', 'REVIEW_URL', '""' buildConfigField 'String', 'REVIEW_URL', '""'
setProperty('archivesBaseName', appName.replaceAll('\\s','') + '-' + defaultConfig.versionCode) base.archivesName = appName.replaceAll('\\s','') + '-' + defaultConfig.versionCode
ndk.debugSymbolLevel = 'full' ndk.debugSymbolLevel = 'full'
} }
@@ -128,10 +128,10 @@ android {
splits.abi { splits.abi {
boolean enabled = project.hasProperty('splitApk') boolean enabled = project.hasProperty('splitApk')
println ('Create separate apks: ' + enabled) println ('Create separate apks: ' + enabled)
enable enabled enable = enabled
reset() reset()
include 'x86', 'armeabi-v7a', 'arm64-v8a', 'x86_64' include 'x86', 'armeabi-v7a', 'arm64-v8a', 'x86_64'
universalApk true universalApk = true
} }
lint { lint {
@@ -144,7 +144,7 @@ android {
disable 'CustomSplashScreen' disable 'CustomSplashScreen'
// https://github.com/organicmaps/organicmaps/issues/3610 // https://github.com/organicmaps/organicmaps/issues/3610
disable 'InsecureBaseConfiguration' disable 'InsecureBaseConfiguration'
abortOnError true abortOnError = true
} }
gradle.projectsEvaluated { gradle.projectsEvaluated {
@@ -204,7 +204,7 @@ android {
applicationIdSuffix '.debug' // Allows to install debug and release builds together applicationIdSuffix '.debug' // Allows to install debug and release builds together
versionNameSuffix '-debug' versionNameSuffix '-debug'
zipAlignEnabled true zipAlignEnabled true
signingConfig signingConfigs.debug signingConfig = signingConfigs.debug
resValue 'string', 'app_name', 'CoMaps Debug' resValue 'string', 'app_name', 'CoMaps Debug'
} }
@@ -212,15 +212,16 @@ android {
if (taskName.contains('release')) { if (taskName.contains('release')) {
if (secureReleasePropertiesFileExists) { if (secureReleasePropertiesFileExists) {
println('Using RELEASE signing keys from secure.properties.release') println('Using RELEASE signing keys from secure.properties.release')
signingConfig signingConfigs.release signingConfig = signingConfigs.release
} else { } else {
println('NO RELEASE signing keys found') println('NO RELEASE signing keys found')
println('Using DEBUG signing keys') println('Using DEBUG signing keys')
signingConfig signingConfigs.debug signingConfig = signingConfigs.debug
} }
} }
minifyEnabled true minifyEnabled true
shrinkResources true shrinkResources = true
// Includes the default ProGuard rules files that are packaged with the Android Gradle plugin. // 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. // To learn more, go to the documentation section about R8 configuration files.
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
@@ -233,15 +234,15 @@ android {
if (taskName.contains('beta')) { if (taskName.contains('beta')) {
if (secureTestPropertiesFileExists) { if (secureTestPropertiesFileExists) {
println('Using TEST signing keys from secure.properties.test') println('Using TEST signing keys from secure.properties.test')
signingConfig signingConfigs.test signingConfig = signingConfigs.test
} else { } else {
println('NO TEST signing keys found') println('NO TEST signing keys found')
println('Using DEBUG signing keys') println('Using DEBUG signing keys')
signingConfig signingConfigs.debug signingConfig = signingConfigs.debug
} }
} }
minifyEnabled true minifyEnabled true
shrinkResources true shrinkResources = true
// Includes the default ProGuard rules files that are packaged with the Android Gradle plugin. // 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. // To learn more, go to the documentation section about R8 configuration files.
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 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. // 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. // TODO: Load all minor files via separate call to ReadAsString which can correctly handle compressed files in zip containers.
androidResources { androidResources {
ignoreAssetsPattern '!.svn:!.git:!.DS_Store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~' ignoreAssetsPattern = '!.svn:!.git:!.DS_Store:!*.scc:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~'
noCompress = ['txt', 'bin', 'html', 'png', 'json', 'mwm', 'ttf', 'sdf', 'ui', 'config', 'csv', 'spv', 'obj'] noCompress = ['txt', 'bin', 'html', 'png', 'json', 'mwm', 'ttf', 'sdf', 'ui', 'config', 'csv', 'spv', 'obj']
localeFilters += [ localeFilters += [
"af", "af",
@@ -310,7 +311,7 @@ android {
} }
compileOptions { compileOptions {
coreLibraryDesugaringEnabled true coreLibraryDesugaringEnabled = true
sourceCompatibility JavaVersion.VERSION_17 sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17

View File

@@ -7,19 +7,17 @@ plugins {
} }
def run(cmd) { def run(cmd) {
def stdout = new ByteArrayOutputStream() def output = providers.exec {
exec {
commandLine = cmd commandLine = cmd
standardOutput = stdout
} }
return stdout.toString() return output.standardOutput.asText.get().trim()
} }
def getVersion() { def getVersion() {
def isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows() def isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows()
def bash = isWindows ? 'C:\\Program Files\\Git\\bin\\bash.exe' : 'bash' 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 versionCode = Integer.parseInt(run([bash, '../tools/unix/version.sh', 'android_code']))
def versionName = run([bash, '../tools/unix/version.sh', 'android_name']).trim() def versionName = run([bash, '../tools/unix/version.sh', 'android_name'])
return new Tuple2(versionCode, versionName) return new Tuple2(versionCode, versionName)
} }

View File

@@ -3,15 +3,15 @@ plugins {
} }
android { android {
namespace 'app.organicmaps.sdk' namespace = 'app.organicmaps.sdk'
compileSdk propCompileSdkVersion.toInteger() compileSdk = propCompileSdkVersion.toInteger()
ndkVersion '28.2.13676358' ndkVersion = '28.2.13676358'
defaultConfig { defaultConfig {
minSdk propMinSdkVersion.toInteger() minSdk = propMinSdkVersion.toInteger()
targetSdk propTargetSdkVersion.toInteger() targetSdk = propTargetSdkVersion.toInteger()
externalNativeBuild { externalNativeBuild {
def pchFlag = 'OFF' def pchFlag = 'OFF'
@@ -85,7 +85,7 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
version '3.22.1+' version = '3.22.1+'
buildStagingDirectory './nativeOutputs' buildStagingDirectory './nativeOutputs'
path '../../CMakeLists.txt' path '../../CMakeLists.txt'
} }

View File

@@ -10,7 +10,7 @@ dependencyResolutionManagement {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
maven { url 'https://www.jitpack.io' } // MPAndroidChart maven { url = 'https://www.jitpack.io' } // MPAndroidChart
} }
} }
rootProject.name = 'CoMaps' rootProject.name = 'CoMaps'