build.gradle 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'com.github.zellius.shortcut-helper'
  3. android {
  4. /*******************************************************
  5. * The following variables:
  6. * - androidBuildToolsVersion,
  7. * - androidCompileSdkVersion
  8. * - qt5AndroidDir - holds the path to qt android files
  9. * needed to build any Qt application
  10. * on Android.
  11. *
  12. * are defined in gradle.properties file. This file is
  13. * updated by QtCreator and androiddeployqt tools.
  14. * Changing them manually might break the compilation!
  15. *******************************************************/
  16. namespace = "eu.vcmi.vcmi"
  17. buildToolsVersion = androidBuildToolsVersion
  18. ndkVersion = androidNdkVersion // Qt generates this property
  19. buildFeatures {
  20. aidl = true
  21. buildConfig = true
  22. }
  23. // Extract native libraries from the APK
  24. packagingOptions.jniLibs.useLegacyPackaging true
  25. defaultConfig {
  26. applicationId "is.xyz.vcmi"
  27. compileSdk = androidCompileSdkVersion.takeAfter("-") as Integer // has "android-" prepended
  28. minSdk = qtMinSdkVersion as Integer
  29. targetSdk = qtTargetSdkVersion as Integer // ANDROID_TARGET_SDK_VERSION in the CMake project
  30. versionCode 1700
  31. versionName "1.7.0"
  32. }
  33. sourceSets {
  34. main {
  35. // Qt requires these to be in the android project root
  36. manifest.srcFile '../AndroidManifest.xml'
  37. jniLibs.srcDirs = ['../libs']
  38. java.srcDirs = [qt5AndroidDir + '/src', 'src', SDL_JAVA_SRC_DIR]
  39. aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
  40. res.srcDirs = [qt5AndroidDir + '/res', 'src/main/res', '../res']
  41. }
  42. }
  43. signingConfigs {
  44. releaseSigning
  45. dailySigning
  46. LoadSigningConfig("releaseSigning")
  47. LoadSigningConfig("dailySigning")
  48. }
  49. buildTypes {
  50. debug {
  51. debuggable true
  52. applicationIdSuffix '.debug'
  53. manifestPlaceholders = [
  54. applicationLabel: 'VCMI debug',
  55. applicationVariant: 'debug',
  56. ]
  57. ndk {
  58. debugSymbolLevel 'full'
  59. }
  60. }
  61. release {
  62. minifyEnabled false
  63. zipAlignEnabled true
  64. applicationIdSuffix = project.findProperty('applicationIdSuffix')
  65. signingConfig = signingConfigs[project.findProperty('signingConfig') ?: 'releaseSigning']
  66. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  67. manifestPlaceholders = [
  68. applicationLabel: project.findProperty('applicationLabel') ?: 'VCMI',
  69. applicationVariant: project.findProperty('applicationVariant') ?: '',
  70. ]
  71. ndk {
  72. debugSymbolLevel 'full'
  73. }
  74. }
  75. }
  76. tasks.withType(JavaCompile) {
  77. options.compilerArgs += ["-Xlint:deprecation"]
  78. }
  79. compileOptions {
  80. sourceCompatibility = JavaVersion.VERSION_17
  81. targetCompatibility = JavaVersion.VERSION_17
  82. }
  83. // Do not compress Qt binary resources file
  84. aaptOptions {
  85. noCompress 'rcc'
  86. }
  87. }
  88. base.archivesName = "vcmi"
  89. shortcutHelper.filePath = "../shortcuts.xml"
  90. def SigningPropertiesPath(final basePath, final signingConfigKey) {
  91. return file("${basePath}/${signingConfigKey}.properties")
  92. }
  93. def SigningKeystorePath(final basePath, final keystoreFileName) {
  94. return file("${basePath}/${keystoreFileName}")
  95. }
  96. def LoadSigningConfig(final signingConfigKey) {
  97. final def props = new Properties()
  98. final def propFile = SigningPropertiesPath(signingRoot, signingConfigKey)
  99. def signingConfig = android.signingConfigs.getAt(signingConfigKey)
  100. if (propFile.canRead()) {
  101. props.load(new FileInputStream(propFile))
  102. if (props != null
  103. && props.containsKey('STORE_FILE')
  104. && props.containsKey('KEY_ALIAS')) {
  105. signingConfig.storeFile = SigningKeystorePath(signingRoot, props['STORE_FILE'])
  106. signingConfig.keyAlias = props['KEY_ALIAS']
  107. if(props.containsKey('STORE_PASSWORD'))
  108. signingConfig.storePassword = props['STORE_PASSWORD']
  109. else
  110. signingConfig.storePassword = System.getenv("ANDROID_STORE_PASSWORD")
  111. if(props.containsKey('KEY_PASSWORD'))
  112. signingConfig.keyPassword = props['KEY_PASSWORD']
  113. else
  114. signingConfig.keyPassword = System.getenv("ANDROID_KEY_PASSWORD")
  115. } else {
  116. println("Some props from signing file are missing")
  117. android.signingConfigs.putAt(signingConfigKey, null)
  118. }
  119. } else {
  120. println("file with signing properties is missing")
  121. android.signingConfigs.putAt(signingConfigKey, null)
  122. }
  123. }
  124. dependencies {
  125. implementation fileTree(dir: '../libs', include: ['*.jar', '*.aar'])
  126. implementation('androidx.annotation:annotation:1.9.1')
  127. // later versions require API level 21
  128. implementation('androidx.appcompat:appcompat:1.6.1')
  129. implementation('androidx.documentfile:documentfile:1.0.1')
  130. }