build.gradle 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. apply plugin: 'com.android.application'
  2. android {
  3. /*******************************************************
  4. * The following variables:
  5. * - androidBuildToolsVersion,
  6. * - androidCompileSdkVersion
  7. * - qt5AndroidDir - holds the path to qt android files
  8. * needed to build any Qt application
  9. * on Android.
  10. *
  11. * are defined in gradle.properties file. This file is
  12. * updated by QtCreator and androiddeployqt tools.
  13. * Changing them manually might break the compilation!
  14. *******************************************************/
  15. namespace = "eu.vcmi.vcmi"
  16. buildToolsVersion = androidBuildToolsVersion
  17. ndkVersion = androidNdkVersion // Qt generates this property
  18. buildFeatures {
  19. aidl = true
  20. buildConfig = true
  21. }
  22. // Extract native libraries from the APK
  23. packagingOptions.jniLibs.useLegacyPackaging true
  24. defaultConfig {
  25. applicationId "is.xyz.vcmi"
  26. compileSdk = androidCompileSdkVersion.takeAfter("-") as Integer // has "android-" prepended
  27. minSdk = qtMinSdkVersion as Integer
  28. targetSdk = qtTargetSdkVersion as Integer // ANDROID_TARGET_SDK_VERSION in the CMake project
  29. versionCode 1700
  30. versionName "1.7.0"
  31. setProperty("archivesBaseName", "vcmi")
  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', 'java']
  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. def SigningPropertiesPath(final basePath, final signingConfigKey) {
  89. return file("${basePath}/${signingConfigKey}.properties")
  90. }
  91. def SigningKeystorePath(final basePath, final keystoreFileName) {
  92. return file("${basePath}/${keystoreFileName}")
  93. }
  94. def LoadSigningConfig(final signingConfigKey) {
  95. final def props = new Properties()
  96. final def propFile = SigningPropertiesPath(signingRoot, signingConfigKey)
  97. def signingConfig = android.signingConfigs.getAt(signingConfigKey)
  98. if (propFile.canRead()) {
  99. props.load(new FileInputStream(propFile))
  100. if (props != null
  101. && props.containsKey('STORE_FILE')
  102. && props.containsKey('KEY_ALIAS')) {
  103. signingConfig.storeFile = SigningKeystorePath(signingRoot, props['STORE_FILE'])
  104. signingConfig.keyAlias = props['KEY_ALIAS']
  105. if(props.containsKey('STORE_PASSWORD'))
  106. signingConfig.storePassword = props['STORE_PASSWORD']
  107. else
  108. signingConfig.storePassword = System.getenv("ANDROID_STORE_PASSWORD")
  109. if(props.containsKey('KEY_PASSWORD'))
  110. signingConfig.keyPassword = props['KEY_PASSWORD']
  111. else
  112. signingConfig.keyPassword = System.getenv("ANDROID_KEY_PASSWORD")
  113. } else {
  114. println("Some props from signing file are missing")
  115. android.signingConfigs.putAt(signingConfigKey, null)
  116. }
  117. } else {
  118. println("file with signing properties is missing")
  119. android.signingConfigs.putAt(signingConfigKey, null)
  120. }
  121. }
  122. dependencies {
  123. implementation fileTree(dir: '../libs', include: ['*.jar', '*.aar'])
  124. implementation 'androidx.annotation:annotation:1.7.1'
  125. implementation 'androidx.documentfile:documentfile:1.0.1'
  126. }