buildscript { repositories { google() mavenCentral() } // Detect flavors from the task name. def taskName = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase() def isFdroid = taskName.contains('fdroid') dependencies { classpath libs.android.tools classpath(libs.triplet.play.publisher) classpath(libs.huawei.publish) } } apply plugin: 'com.android.application' apply plugin: 'com.github.triplet.play' apply plugin: 'ru.cian.huawei-publish-gradle-plugin' import com.github.triplet.gradle.androidpublisher.ReleaseStatus def getCommitMessage() { return run(['git', '--no-pager', 'show', '-s', '--format=%s%n%n%b', 'HEAD']).trim() } project.ext.appId = 'app.comaps' project.ext.appName = 'CoMaps' java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } } android { 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' dependenciesInfo { // Disables dependency metadata when building APKs (for IzzyOnDroid/F-Droid) includeInApk = false // Disables dependency metadata when building Android App Bundles (for Google Play) includeInBundle = false } buildFeatures { dataBinding = true buildConfig = true } // Users are complaining that the app should be re-downloaded from the Play Store after changing the language. bundle { language { enableSplit = false } } // All properties are read from gradle.properties file compileSdk = propCompileSdkVersion.toInteger() defaultConfig { versionCode = rootProject.ext.versionCode versionName = rootProject.ext.versionName println('Version: ' + versionName) println('VersionCode: ' + versionCode) 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', '""' base.archivesName = appName.replaceAll('\\s','') + '-' + defaultConfig.versionCode ndk.debugSymbolLevel = 'full' } flavorDimensions += 'default' productFlavors { // 01 is a historical artefact, sorry. final int HUAWEI_VERSION_CODE_BASE = 01_00_00_00_00 google { dimension 'default' applicationIdSuffix '.google' versionName = android.defaultConfig.versionName + '-Google' buildConfigField 'String', 'SUPPORT_MAIL', '"gplay@comaps.app"' buildConfigField 'String', 'REVIEW_URL', '"market://details?id=app.comaps.google"' } // Distributed directly by the project, e.g. in repo releases, chats, etc. web { dimension 'default' versionName = android.defaultConfig.versionName buildConfigField 'String', 'SUPPORT_MAIL', '"apk@comaps.app"' } fdroid { dimension 'default' applicationIdSuffix '.fdroid' versionName = android.defaultConfig.versionName + '-FDroid' buildConfigField 'String', 'SUPPORT_MAIL', '"fdroid@comaps.app"' } huawei { dimension 'default' applicationIdSuffix '.huawei' versionName = android.defaultConfig.versionName + '-Huawei' versionCode = HUAWEI_VERSION_CODE_BASE + android.defaultConfig.versionCode buildConfigField 'String', 'SUPPORT_MAIL', '"huawei@comaps.app"' buildConfigField 'String', 'REVIEW_URL', '"appmarket://details?id=app.comaps"' } } playConfigs { googleRelease { enabled.set(true) } } splits.abi { boolean enabled = project.hasProperty('splitApk') println ('Create separate apks: ' + enabled) enable = enabled reset() include 'x86', 'armeabi-v7a', 'arm64-v8a', 'x86_64' universalApk = true } lint { disable 'MissingTranslation' // https://github.com/organicmaps/organicmaps/issues/3551 disable 'MissingQuantity', 'UnusedQuantity' // https://github.com/organicmaps/organicmaps/issues/1077 disable 'CustomSplashScreen' // https://github.com/organicmaps/organicmaps/issues/3610 disable 'InsecureBaseConfiguration' abortOnError = true } gradle.projectsEvaluated { android.applicationVariants.all { variant -> def task = variant.name.capitalize() project.task(type: Exec, "run${task}", dependsOn: "install${task}") { commandLine android.getAdbExe(), 'shell', 'am', 'start', '-n', "$applicationId/app.organicmaps.DownloadResourcesActivity", '-a', 'android.intent.action.MAIN', '-c', 'android.intent.category.LAUNCHER' } } } def secureReleasePropertiesFileExists = file('secure.properties.release').exists() if (secureReleasePropertiesFileExists) { apply from: 'secure.properties.release' } def secureTestPropertiesFileExists = file('secure.properties.test').exists() if (secureTestPropertiesFileExists) { apply from: 'secure.properties.test' } signingConfigs { debug { storeFile file('comaps-debug.keystore') storePassword '12345678' keyAlias 'CoMaps Debug' keyPassword '12345678' } test { if (secureTestPropertiesFileExists) { storeFile file(secretTestStoreFile) storePassword secretTestStorePassword keyAlias secretTestKeyAlias keyPassword secretTestKeyPassword } else { println('secure.properties.test doesn\'t exist') } } release { if (secureReleasePropertiesFileExists) { storeFile file(secretReleaseStoreFile) storePassword secretReleaseStorePassword keyAlias secretReleaseKeyAlias keyPassword secretReleaseKeyPassword } else { println('secure.properties.release doesn\'t exist') } } } buildTypes { def taskName = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase() debug { applicationIdSuffix '.debug' // Allows to install debug and release builds together versionNameSuffix '-debug' zipAlignEnabled true signingConfig = signingConfigs.debug resValue 'string', 'app_name', 'CoMaps Debug' } release { if (taskName.contains('release')) { if (secureReleasePropertiesFileExists) { println('Using RELEASE signing keys from secure.properties.release') signingConfig = signingConfigs.release } else { println('NO RELEASE signing keys found') println('Using DEBUG signing keys') signingConfig = signingConfigs.debug } } minifyEnabled 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' resValue 'string', 'app_name', project.ext.appName } beta { applicationIdSuffix '.test' versionNameSuffix '-test' if (taskName.contains('beta')) { if (secureTestPropertiesFileExists) { println('Using TEST signing keys from secure.properties.test') signingConfig = signingConfigs.test } else { println('NO TEST signing keys found') println('Using DEBUG signing keys') signingConfig = signingConfigs.debug } } minifyEnabled 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' matchingFallbacks = ['release'] // use dependencies of "release" build type resValue 'string', 'app_name', 'CoMaps Test' } } // 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:.*: