build.gradle 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs
  2. plugins {
  3. id 'org.sonarqube'
  4. id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
  5. }
  6. apply plugin: 'com.android.application'
  7. apply plugin: 'kotlin-android'
  8. apply plugin: 'kotlin-kapt'
  9. // only apply the plugin if we are dealing with a AppGallery build
  10. if (getGradle().getStartParameter().getTaskRequests().toString().contains("Hms")) {
  11. println "enabling hms plugin"
  12. apply plugin: 'com.huawei.agconnect'
  13. }
  14. // version codes
  15. // Only use the scheme "<major>.<minor>.<patch>" for the app_version
  16. def app_version = "5.4"
  17. // beta_suffix with leading dash (e.g. `-beta1`)
  18. // should be one of (alpha|beta|rc) and an increasing number or empty for a regular release.
  19. // Note: in nightly builds this will be overwritten with a nightly version "-n12345"
  20. def beta_suffix = ""
  21. def defaultVersionCode = 973
  22. /**
  23. * Return the git hash, if git is installed.
  24. */
  25. def getGitHash = { ->
  26. def stdout = new ByteArrayOutputStream()
  27. def stderr = new ByteArrayOutputStream()
  28. try {
  29. exec {
  30. commandLine 'git', 'rev-parse', '--short', 'HEAD'
  31. standardOutput = stdout
  32. errorOutput = stderr
  33. ignoreExitValue true
  34. }
  35. } catch (ignored) { /* If git binary is not found, carry on */ }
  36. def hash = stdout.toString().trim()
  37. return (hash.isEmpty()) ? "?" : hash
  38. }
  39. /**
  40. * Look up the keystore with the specified name in a `keystore` directory
  41. * adjacent to this project directory. If it exists, return a signing config.
  42. * Otherwise, return null.
  43. */
  44. def findKeystore = { name ->
  45. def basePath = "${projectDir.getAbsolutePath()}/../../keystore"
  46. def storePath = "${basePath}/${name}.keystore"
  47. def storeFile = new File(storePath)
  48. if (storeFile.exists() && storeFile.isFile()) {
  49. def propertiesPath = "${basePath}/${name}.properties"
  50. def propertiesFile = new File(propertiesPath)
  51. if (propertiesFile.exists() && propertiesFile.isFile()) {
  52. Properties props = new Properties()
  53. propertiesFile.withInputStream { props.load(it) }
  54. return [
  55. storeFile: storePath,
  56. storePassword: props.storePassword,
  57. keyAlias: props.keyAlias,
  58. keyPassword: props.keyPassword,
  59. ]
  60. } else {
  61. return [
  62. storeFile: storePath,
  63. storePassword: null,
  64. keyAlias: null,
  65. keyPassword: null,
  66. ]
  67. }
  68. }
  69. }
  70. /**
  71. * Map with keystore paths (if found).
  72. */
  73. def keystores = [
  74. debug: findKeystore("debug"),
  75. release: findKeystore("threema"),
  76. hms_release: findKeystore("threema_hms"),
  77. onprem_release: findKeystore("onprem"),
  78. blue_release: findKeystore("threema_blue"),
  79. ]
  80. android {
  81. // NOTE: When adjusting compileSdkVersion, buildToolsVersion or ndkVersion,
  82. // make sure to adjust them in `scripts/Dockerfile` and
  83. // `.gitlab-ci.yml` as well!
  84. compileSdk 34
  85. buildToolsVersion = '34.0.0'
  86. ndkVersion '25.2.9519653'
  87. defaultConfig {
  88. // https://developer.android.com/training/testing/espresso/setup#analytics
  89. testInstrumentationRunnerArguments notAnnotation: 'ch.threema.app.TestFastlaneOnly,ch.threema.app.DangerousTest', disableAnalytics: 'true'
  90. minSdkVersion 21
  91. //noinspection OldTargetApi
  92. targetSdkVersion 33
  93. vectorDrawables.useSupportLibrary = true
  94. applicationId "ch.threema.app"
  95. testApplicationId 'ch.threema.app.test'
  96. versionCode defaultVersionCode
  97. versionName "${app_version}${beta_suffix}"
  98. resValue "string", "app_name", "Threema"
  99. // package name used for sync adapter - needs to match mime types below
  100. resValue "string", "package_name", applicationId
  101. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.profile"
  102. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.call"
  103. buildConfigField "int", "MAX_GROUP_SIZE", "256"
  104. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"g-\""
  105. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.g-\""
  106. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.threema.ch\""
  107. buildConfigField "int[]", "CHAT_SERVER_PORTS", "{5222, 443}"
  108. buildConfigField "String", "MEDIA_PATH", "\"Threema\""
  109. buildConfigField "boolean", "CHAT_SERVER_GROUPS", "true"
  110. buildConfigField "boolean", "DISABLE_CERT_PINNING", "false"
  111. buildConfigField "boolean", "VIDEO_CALLS_ENABLED", "true"
  112. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x45, (byte) 0x0b, (byte) 0x97, (byte) 0x57, (byte) 0x35, (byte) 0x27, (byte) 0x9f, (byte) 0xde, (byte) 0xcb, (byte) 0x33, (byte) 0x13, (byte) 0x64, (byte) 0x8f, (byte) 0x5f, (byte) 0xc6, (byte) 0xee, (byte) 0x9f, (byte) 0xf4, (byte) 0x36, (byte) 0x0e, (byte) 0xa9, (byte) 0x2a, (byte) 0x8c, (byte) 0x17, (byte) 0x51, (byte) 0xc6, (byte) 0x61, (byte) 0xe4, (byte) 0xc0, (byte) 0xd8, (byte) 0xc9, (byte) 0x09 }"
  113. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0xda, (byte) 0x7c, (byte) 0x73, (byte) 0x79, (byte) 0x8f, (byte) 0x97, (byte) 0xd5, (byte) 0x87, (byte) 0xc3, (byte) 0xa2, (byte) 0x5e, (byte) 0xbe, (byte) 0x0a, (byte) 0x91, (byte) 0x41, (byte) 0x7f, (byte) 0x76, (byte) 0xdb, (byte) 0xcc, (byte) 0xcd, (byte) 0xda, (byte) 0x29, (byte) 0x30, (byte) 0xe6, (byte) 0xa9, (byte) 0x09, (byte) 0x0a, (byte) 0xf6, (byte) 0x2e, (byte) 0xba, (byte) 0x6f, (byte) 0x15 }"
  114. buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
  115. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.threema.ch/\""
  116. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.threema.ch/\""
  117. buildConfigField "String", "WORK_SERVER_URL", "null"
  118. buildConfigField "String", "WORK_SERVER_IPV6_URL", "null"
  119. buildConfigField "String", "MEDIATOR_SERVER_URL", "\"wss://mediator-{deviceGroupIdPrefix4}.threema.ch/{deviceGroupIdPrefix8}\""
  120. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_URL", "\"https://blobp-{blobIdPrefix}.threema.ch/{blobId}\""
  121. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_IPV6_URL", "\"https://ds-blobp-{blobIdPrefix}.threema.ch/{blobId}\""
  122. buildConfigField "String", "BLOB_SERVER_DONE_URL", "\"https://blobp-{blobIdPrefix}.threema.ch/{blobId}/done\""
  123. buildConfigField "String", "BLOB_SERVER_DONE_IPV6_URL", "\"https://ds-blobp-{blobIdPrefix}.threema.ch/{blobId}/done\""
  124. buildConfigField "String", "BLOB_SERVER_UPLOAD_URL", "\"https://blobp-upload.threema.ch/upload\""
  125. buildConfigField "String", "BLOB_SERVER_UPLOAD_IPV6_URL", "\"https://ds-blobp-upload.threema.ch/upload\""
  126. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.threema.ch/\""
  127. buildConfigField "String", "SAFE_SERVER_URL", "\"https://safe-{backupIdPrefix8}.threema.ch/\""
  128. buildConfigField "String", "WEB_SERVER_URL", "\"https://web.threema.ch/\""
  129. buildConfigField "String", "APP_RATING_URL", "\"https://threema.ch/app-rating/android/{rating}\""
  130. buildConfigField "byte[]", "THREEMA_PUSH_PUBLIC_KEY", "new byte[] {(byte) 0xfd, (byte) 0x71, (byte) 0x1e, (byte) 0x1a, (byte) 0x0d, (byte) 0xb0, (byte) 0xe2, (byte) 0xf0, (byte) 0x3f, (byte) 0xca, (byte) 0xab, (byte) 0x6c, (byte) 0x43, (byte) 0xda, (byte) 0x25, (byte) 0x75, (byte) 0xb9, (byte) 0x51, (byte) 0x36, (byte) 0x64, (byte) 0xa6, (byte) 0x2a, (byte) 0x12, (byte) 0xbd, (byte) 0x07, (byte) 0x28, (byte) 0xd8, (byte) 0x7f, (byte) 0x71, (byte) 0x25, (byte) 0xcc, (byte) 0x24}"
  131. buildConfigField "String", "ONPREM_ID_PREFIX", "\"O\""
  132. buildConfigField "String", "LOG_TAG", "\"3ma\""
  133. buildConfigField "String", "DEFAULT_APP_THEME", "\"2\""
  134. buildConfigField "String[]", "ONPREM_CONFIG_TRUSTED_PUBLIC_KEYS", "null"
  135. buildConfigField "boolean", "MD_ENABLED", "false"
  136. buildConfigField "boolean", "EDIT_MESSAGES_ENABLED", "false"
  137. buildConfigField "boolean", "DELETE_MESSAGES_ENABLED", "false"
  138. // config fields for action URLs / deep links
  139. buildConfigField "String", "uriScheme", "\"threema\""
  140. buildConfigField "String", "actionUrl", "\"go.threema.ch\""
  141. buildConfigField "String", "contactActionUrl", "\"threema.id\""
  142. buildConfigField "String", "groupLinkActionUrl", "\"threema.group\""
  143. // duplicated for manifest
  144. manifestPlaceholders = [
  145. uriScheme: "threema",
  146. contactActionUrl: "threema.id",
  147. groupLinkActionUrl: "threema.group",
  148. actionUrl: "go.threema.ch",
  149. callMimeType: "vnd.android.cursor.item/vnd.ch.threema.app.call",
  150. ]
  151. testInstrumentationRunner 'ch.threema.app.ThreemaTestRunner'
  152. // Only include language resources for those languages
  153. resourceConfigurations += [
  154. "en",
  155. "be-rBY",
  156. "ca",
  157. "cs",
  158. "de",
  159. "es",
  160. "fr",
  161. "gsw",
  162. "hu",
  163. "it",
  164. "ja",
  165. "nl-rNL",
  166. "no",
  167. "pl",
  168. "pt-rBR",
  169. "rm",
  170. "ru",
  171. "sk",
  172. "tr",
  173. "uk",
  174. "zh-rCN",
  175. "zh-rTW"
  176. ]
  177. }
  178. splits {
  179. abi {
  180. enable true
  181. reset()
  182. include 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'
  183. exclude 'armeabi', 'mips', 'mips64'
  184. universalApk project.hasProperty("buildUniversalApk")
  185. }
  186. }
  187. // Assign different version code for each output
  188. def abiVersionCodes = ['armeabi-v7a': 2, 'arm64-v8a': 3, 'x86': 8, 'x86_64': 9]
  189. android.applicationVariants.all { variant ->
  190. variant.outputs.each { output ->
  191. def abi = output.getFilter("ABI")
  192. output.versionCodeOverride =
  193. abiVersionCodes.get(abi, 0) * 1000000 + defaultVersionCode
  194. }
  195. }
  196. namespace 'ch.threema.app'
  197. flavorDimensions "default"
  198. productFlavors {
  199. none { }
  200. store_google { }
  201. store_threema {
  202. resValue "string", "shop_download_filename", "Threema-update.apk"
  203. }
  204. store_google_work {
  205. versionName "${app_version}k${beta_suffix}"
  206. applicationId "ch.threema.app.work"
  207. testApplicationId 'ch.threema.app.work.test'
  208. resValue "string", "app_name", "Threema Work"
  209. resValue "string", "package_name", applicationId
  210. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.profile"
  211. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.call"
  212. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  213. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  214. buildConfigField "String", "MEDIA_PATH", "\"ThreemaWork\""
  215. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.threema.ch/\""
  216. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.threema.ch/\""
  217. buildConfigField "String", "APP_RATING_URL", "\"https://threema.ch/app-rating/android-work/{rating}\""
  218. buildConfigField "String", "LOG_TAG", "\"3mawrk\""
  219. buildConfigField "String", "DEFAULT_APP_THEME", "\"2\""
  220. // config fields for action URLs / deep links
  221. buildConfigField "String", "uriScheme", "\"threemawork\""
  222. buildConfigField "String", "actionUrl", "\"work.threema.ch\""
  223. manifestPlaceholders = [
  224. uriScheme: "threemawork",
  225. actionUrl: "work.threema.ch",
  226. callMimeType: "vnd.android.cursor.item/vnd.ch.threema.app.work.call",
  227. ]
  228. }
  229. green {
  230. // The app was previously named `sandbox`. The app id remains unchanged to still be able to install updates.
  231. applicationId "ch.threema.app.sandbox"
  232. testApplicationId 'ch.threema.app.sandbox.test'
  233. resValue "string", "app_name", "Threema Green"
  234. resValue "string", "package_name", applicationId
  235. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.profile"
  236. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.call"
  237. buildConfigField "String", "MEDIA_PATH", "\"ThreemaGreen\""
  238. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.test.threema.ch\""
  239. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  240. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  241. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.test.threema.ch/\""
  242. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.test.threema.ch/\""
  243. buildConfigField "String", "MEDIATOR_SERVER_URL", "\"wss://mediator-{deviceGroupIdPrefix4}.test.threema.ch/{deviceGroupIdPrefix8}\""
  244. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.test.threema.ch/\""
  245. buildConfigField "String", "APP_RATING_URL", "\"https://test.threema.ch/app-rating/android/{rating}\""
  246. buildConfigField "boolean", "MD_ENABLED", "true"
  247. buildConfigField "boolean", "EDIT_MESSAGES_ENABLED", "true"
  248. buildConfigField "boolean", "DELETE_MESSAGES_ENABLED", "true"
  249. }
  250. sandbox_work {
  251. versionName "${app_version}k${beta_suffix}"
  252. applicationId "ch.threema.app.sandbox.work"
  253. testApplicationId 'ch.threema.app.sandbox.work.test'
  254. resValue "string", "app_name", "Threema Sandbox Work"
  255. resValue "string", "package_name", applicationId
  256. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.work.profile"
  257. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.work.call"
  258. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  259. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  260. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.test.threema.ch\""
  261. buildConfigField "String", "MEDIA_PATH", "\"ThreemaWorkSandbox\""
  262. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  263. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  264. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.test.threema.ch/\""
  265. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.test.threema.ch/\""
  266. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.test.threema.ch/\""
  267. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.test.threema.ch/\""
  268. buildConfigField "String", "MEDIATOR_SERVER_URL", "\"wss://mediator-{deviceGroupIdPrefix4}.test.threema.ch/{deviceGroupIdPrefix8}\""
  269. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.test.threema.ch/\""
  270. buildConfigField "String", "APP_RATING_URL", "\"https://test.threema.ch/app-rating/android-work/{rating}\""
  271. buildConfigField "String", "LOG_TAG", "\"3mawrk\""
  272. buildConfigField "String", "DEFAULT_APP_THEME", "\"2\""
  273. // config fields for action URLs / deep links
  274. buildConfigField "String", "uriScheme", "\"threemawork\""
  275. buildConfigField "String", "actionUrl", "\"work.test.threema.ch\""
  276. buildConfigField "boolean", "MD_ENABLED", "true"
  277. buildConfigField "boolean", "EDIT_MESSAGES_ENABLED", "true"
  278. buildConfigField "boolean", "DELETE_MESSAGES_ENABLED", "true"
  279. manifestPlaceholders = [
  280. uriScheme : "threemawork",
  281. actionUrl : "work.test.threema.ch",
  282. ]
  283. }
  284. onprem {
  285. versionName "${app_version}o${beta_suffix}"
  286. applicationId "ch.threema.app.onprem"
  287. testApplicationId 'ch.threema.app.onprem.test'
  288. resValue "string", "app_name", "Threema OnPrem"
  289. resValue "string", "package_name", applicationId
  290. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.onprem.profile"
  291. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.onprem.call"
  292. buildConfigField "int", "MAX_GROUP_SIZE", "256"
  293. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"\""
  294. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"\""
  295. buildConfigField "String", "CHAT_SERVER_SUFFIX", "null"
  296. buildConfigField "String", "MEDIA_PATH", "\"ThreemaOnPrem\""
  297. buildConfigField "boolean", "CHAT_SERVER_GROUPS", "false"
  298. buildConfigField "byte[]", "SERVER_PUBKEY", "null"
  299. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "null"
  300. buildConfigField "String", "DIRECTORY_SERVER_URL", "null"
  301. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "null"
  302. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_URL", "null"
  303. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_IPV6_URL", "null"
  304. buildConfigField "String", "BLOB_SERVER_DONE_URL", "null"
  305. buildConfigField "String", "BLOB_SERVER_DONE_IPV6_URL", "null"
  306. buildConfigField "String", "BLOB_SERVER_UPLOAD_URL", "null"
  307. buildConfigField "String", "BLOB_SERVER_UPLOAD_IPV6_URL", "null"
  308. buildConfigField "String[]", "ONPREM_CONFIG_TRUSTED_PUBLIC_KEYS", "new String[] {\"ek1qBp4DyRmLL9J5sCmsKSfwbsiGNB4veDAODjkwe/k=\", \"Hrk8aCjwKkXySubI7CZ3y9Sx+oToEHjNkGw98WSRneU=\", \"5pEn1T/5bhecNWrp9NgUQweRfgVtu/I8gRb3VxGP7k4=\"}"
  309. buildConfigField "String", "LOG_TAG", "\"3maop\""
  310. // config fields for action URLs / deep links
  311. buildConfigField "String", "uriScheme", "\"threemaonprem\""
  312. buildConfigField "String", "actionUrl", "\"onprem.threema.ch\""
  313. manifestPlaceholders = [
  314. uriScheme: "threemaonprem",
  315. actionUrl: "onprem.threema.ch",
  316. callMimeType: "vnd.android.cursor.item/vnd.ch.threema.app.onprem.call",
  317. ]
  318. }
  319. onprem_internal {
  320. versionName "${app_version}o${beta_suffix}"
  321. applicationId "ch.threema.app.onprem.internal"
  322. testApplicationId 'ch.threema.app.onprem.internal.test'
  323. resValue "string", "app_name", "Threema OnPrem Internal"
  324. resValue "string", "package_name", applicationId
  325. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.onprem.internal.profile"
  326. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.onprem.internal.call"
  327. buildConfigField "int", "MAX_GROUP_SIZE", "256"
  328. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"\""
  329. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"\""
  330. buildConfigField "String", "CHAT_SERVER_SUFFIX", "null"
  331. buildConfigField "String", "MEDIA_PATH", "\"ThreemaOnPremInt\""
  332. buildConfigField "boolean", "CHAT_SERVER_GROUPS", "false"
  333. buildConfigField "byte[]", "SERVER_PUBKEY", "null"
  334. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "null"
  335. buildConfigField "String", "DIRECTORY_SERVER_URL", "null"
  336. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "null"
  337. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_URL", "null"
  338. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_IPV6_URL", "null"
  339. buildConfigField "String", "BLOB_SERVER_DONE_URL", "null"
  340. buildConfigField "String", "BLOB_SERVER_DONE_IPV6_URL", "null"
  341. buildConfigField "String", "BLOB_SERVER_UPLOAD_URL", "null"
  342. buildConfigField "String", "BLOB_SERVER_UPLOAD_IPV6_URL", "null"
  343. buildConfigField "String[]", "ONPREM_CONFIG_TRUSTED_PUBLIC_KEYS", "new String[] {\"ek1qBp4DyRmLL9J5sCmsKSfwbsiGNB4veDAODjkwe/k=\", \"Hrk8aCjwKkXySubI7CZ3y9Sx+oToEHjNkGw98WSRneU=\", \"5pEn1T/5bhecNWrp9NgUQweRfgVtu/I8gRb3VxGP7k4=\"}"
  344. buildConfigField "String", "LOG_TAG", "\"3maoi\""
  345. // config fields for action URLs / deep links
  346. buildConfigField "String", "uriScheme", "\"threemaonprem\""
  347. buildConfigField "String", "actionUrl", "\"onprem.threema.ch\""
  348. manifestPlaceholders = [
  349. uriScheme: "threemaonprem",
  350. actionUrl: "onprem.threema.ch",
  351. callMimeType: "vnd.android.cursor.item/vnd.ch.threema.app.onprem.internal.call",
  352. ]
  353. }
  354. blue { // Essentially like sandbox work, but with a different icon and accent color, used for internal testing
  355. versionName "${app_version}r${beta_suffix}"
  356. // The app was previously named `red`. The app id remains unchanged to still be able to install updates.
  357. applicationId "ch.threema.app.red"
  358. testApplicationId 'ch.threema.app.blue.test'
  359. resValue "string", "app_name", "Threema Blue"
  360. resValue "string", "package_name", applicationId
  361. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.blue.profile"
  362. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.blue.call"
  363. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  364. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  365. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.test.threema.ch\""
  366. buildConfigField "String", "MEDIA_PATH", "\"ThreemaBlue\""
  367. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  368. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  369. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.test.threema.ch/\""
  370. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.test.threema.ch/\""
  371. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.test.threema.ch/\""
  372. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.test.threema.ch/\""
  373. buildConfigField "String", "MEDIATOR_SERVER_URL", "\"wss://mediator-{deviceGroupIdPrefix4}.test.threema.ch/{deviceGroupIdPrefix8}\""
  374. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.test.threema.ch/\""
  375. buildConfigField "String", "APP_RATING_URL", "\"https://test.threema.ch/app-rating/android-work/{rating}\""
  376. buildConfigField "String", "LOG_TAG", "\"3mablue\""
  377. buildConfigField "boolean", "EDIT_MESSAGES_ENABLED", "true"
  378. buildConfigField "boolean", "DELETE_MESSAGES_ENABLED", "true"
  379. // config fields for action URLs / deep links
  380. buildConfigField "String", "uriScheme", "\"threemablue\""
  381. buildConfigField "String", "actionUrl", "\"blue.threema.ch\""
  382. manifestPlaceholders = [
  383. uriScheme: "threemablue",
  384. actionUrl: "blue.threema.ch",
  385. callMimeType: "vnd.android.cursor.item/vnd.ch.threema.app.blue.call",
  386. ]
  387. }
  388. hms {
  389. applicationId "ch.threema.app.hms"
  390. }
  391. hms_work {
  392. versionName "${app_version}k${beta_suffix}"
  393. applicationId "ch.threema.app.work.hms"
  394. testApplicationId 'ch.threema.app.work.test.hms'
  395. resValue "string", "app_name", "Threema Work"
  396. resValue "string", "package_name", "ch.threema.app.work"
  397. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.profile"
  398. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.call"
  399. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  400. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  401. buildConfigField "String", "MEDIA_PATH", "\"ThreemaWork\""
  402. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.threema.ch/\""
  403. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.threema.ch/\""
  404. buildConfigField "String", "APP_RATING_URL", "\"https://threema.ch/app-rating/android-work/{rating}\""
  405. buildConfigField "String", "LOG_TAG", "\"3mawrk\""
  406. buildConfigField "String", "DEFAULT_APP_THEME", "\"2\""
  407. // config fields for action URLs / deep links
  408. buildConfigField "String", "uriScheme", "\"threemawork\""
  409. buildConfigField "String", "actionUrl", "\"work.threema.ch\""
  410. manifestPlaceholders = [
  411. uriScheme: "threemawork",
  412. actionUrl: "work.threema.ch",
  413. callMimeType: "vnd.android.cursor.item/vnd.ch.threema.app.work.call",
  414. ]
  415. }
  416. libre {
  417. versionName "${app_version}l${beta_suffix}"
  418. applicationId "ch.threema.app.libre"
  419. testApplicationId 'ch.threema.app.libre.test'
  420. resValue "string", "package_name", applicationId
  421. resValue "string", "app_name", "Threema Libre"
  422. buildConfigField "String", "MEDIA_PATH", "\"ThreemaLibre\""
  423. }
  424. }
  425. signingConfigs {
  426. // Debug config
  427. if (keystores.debug != null) {
  428. debug {
  429. storeFile file(keystores.debug.storeFile)
  430. }
  431. } else {
  432. logger.warn("No debug keystore found. Falling back to locally generated keystore.")
  433. }
  434. // Release config
  435. if (keystores.release != null) {
  436. release {
  437. storeFile file(keystores.release.storeFile)
  438. storePassword keystores.release.storePassword
  439. keyAlias keystores.release.keyAlias
  440. keyPassword keystores.release.keyPassword
  441. }
  442. } else {
  443. logger.warn("No release keystore found. Falling back to locally generated keystore.")
  444. }
  445. // Release config
  446. if (keystores.hms_release != null) {
  447. hms_release {
  448. storeFile file(keystores.hms_release.storeFile)
  449. storePassword keystores.hms_release.storePassword
  450. keyAlias keystores.hms_release.keyAlias
  451. keyPassword keystores.hms_release.keyPassword
  452. }
  453. } else {
  454. logger.warn("No hms keystore found. Falling back to locally generated keystore.")
  455. }
  456. // Onprem release config
  457. if (keystores.onprem_release != null) {
  458. onprem_release {
  459. storeFile file(keystores.onprem_release.storeFile)
  460. storePassword keystores.onprem_release.storePassword
  461. keyAlias keystores.onprem_release.keyAlias
  462. keyPassword keystores.onprem_release.keyPassword
  463. }
  464. } else {
  465. logger.warn("No onprem keystore found. Falling back to locally generated keystore.")
  466. }
  467. // Blue release config
  468. if (keystores.blue_release != null) {
  469. blue_release {
  470. storeFile file(keystores.blue_release.storeFile)
  471. storePassword keystores.blue_release.storePassword
  472. keyAlias keystores.blue_release.keyAlias
  473. keyPassword keystores.blue_release.keyPassword
  474. }
  475. } else {
  476. logger.warn("No blue keystore found. Falling back to locally generated keystore.")
  477. }
  478. // Note: Libre release is signed with HSM, no config here
  479. }
  480. sourceSets {
  481. main {
  482. assets.srcDirs = ['assets']
  483. jniLibs.srcDirs = ['libs']
  484. }
  485. // Based on Google services
  486. none {
  487. java.srcDir 'src/google_services_based/java'
  488. }
  489. store_google {
  490. java.srcDir 'src/google_services_based/java'
  491. }
  492. store_google_work {
  493. java.srcDir 'src/google_services_based/java'
  494. }
  495. store_threema {
  496. java.srcDir 'src/google_services_based/java'
  497. }
  498. libre {
  499. assets.srcDirs = ['src/foss_based/assets']
  500. java.srcDir 'src/foss_based/java'
  501. }
  502. onprem {
  503. java.srcDir 'src/google_services_based/java'
  504. }
  505. onprem_internal {
  506. java.srcDir 'src/google_services_based/java'
  507. }
  508. green {
  509. java.srcDir 'src/google_services_based/java'
  510. manifest.srcFile 'src/store_google/AndroidManifest.xml'
  511. }
  512. sandbox_work {
  513. java.srcDir 'src/google_services_based/java'
  514. res.srcDir 'src/store_google_work/res'
  515. manifest.srcFile 'src/store_google_work/AndroidManifest.xml'
  516. }
  517. blue {
  518. java.srcDir 'src/google_services_based/java'
  519. res.srcDir 'src/blue/res'
  520. }
  521. // Based on Huawei services
  522. hms {
  523. java.srcDir 'src/hms_services_based/java'
  524. }
  525. hms_work {
  526. java.srcDir 'src/hms_services_based/java'
  527. res.srcDir 'src/store_google_work/res'
  528. }
  529. // FOSS, no proprietary services
  530. libre {
  531. assets.srcDirs = ['src/foss_based/assets']
  532. java.srcDir 'src/foss_based/java'
  533. }
  534. }
  535. buildTypes {
  536. debug {
  537. debuggable true
  538. jniDebuggable false
  539. ndk {
  540. debugSymbolLevel 'FULL'
  541. }
  542. enableUnitTestCoverage false
  543. enableAndroidTestCoverage false
  544. if (keystores['debug'] != null) {
  545. signingConfig signingConfigs.debug
  546. }
  547. }
  548. release {
  549. debuggable false
  550. jniDebuggable false
  551. minifyEnabled true
  552. shrinkResources false // Caused inconsistencies between local and CI builds
  553. vcsInfo.include false // For reproducible builds independent from git history
  554. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
  555. ndk {
  556. debugSymbolLevel 'FULL' // 'SYMBOL_TABLE'
  557. }
  558. if (keystores['release'] != null) {
  559. productFlavors.store_google.signingConfig signingConfigs.release
  560. productFlavors.store_google_work.signingConfig signingConfigs.release
  561. productFlavors.store_threema.signingConfig signingConfigs.release
  562. productFlavors.green.signingConfig signingConfigs.release
  563. productFlavors.sandbox_work.signingConfig signingConfigs.release
  564. productFlavors.none.signingConfig signingConfigs.release
  565. }
  566. if (keystores['hms_release'] != null) {
  567. productFlavors.hms.signingConfig signingConfigs.hms_release
  568. productFlavors.hms_work.signingConfig signingConfigs.hms_release
  569. }
  570. if (keystores['onprem_release'] != null) {
  571. productFlavors.onprem.signingConfig signingConfigs.onprem_release
  572. }
  573. if (keystores['blue_release'] != null) {
  574. productFlavors.blue.signingConfig signingConfigs.blue_release
  575. }
  576. // Note: Libre release is signed with HSM, no config here
  577. }
  578. }
  579. // Only build relevant buildType / flavor combinations
  580. variantFilter { variant ->
  581. def names = variant.flavors*.name
  582. if (
  583. variant.buildType.name == "release" && (
  584. names.contains("green") || names.contains("sandbox_work")
  585. )
  586. ) {
  587. setIgnore(true)
  588. }
  589. }
  590. externalNativeBuild {
  591. ndkBuild {
  592. path 'jni/Android.mk'
  593. }
  594. }
  595. packagingOptions {
  596. jniLibs {
  597. // replacement for extractNativeLibs in AndroidManifest
  598. useLegacyPackaging = true
  599. }
  600. resources {
  601. excludes += [
  602. 'META-INF/DEPENDENCIES.txt',
  603. 'META-INF/LICENSE.txt',
  604. 'META-INF/NOTICE.txt',
  605. 'META-INF/NOTICE',
  606. 'META-INF/LICENSE',
  607. 'META-INF/DEPENDENCIES',
  608. 'META-INF/notice.txt',
  609. 'META-INF/license.txt',
  610. 'META-INF/dependencies.txt',
  611. 'META-INF/LGPL2.1',
  612. '**/*.proto',
  613. 'DebugProbesKt.bin'
  614. ]
  615. }
  616. }
  617. testOptions {
  618. // Disable animations in instrumentation tests
  619. animationsDisabled true
  620. unitTests {
  621. all {
  622. // All the usual Gradle options.
  623. testLogging {
  624. events "passed", "skipped", "failed", "standardOut", "standardError"
  625. outputs.upToDateWhen { false }
  626. exceptionFormat = 'full'
  627. }
  628. jvmArgs = jvmArgs + ['--add-opens=java.base/java.util=ALL-UNNAMED']
  629. jvmArgs = jvmArgs + ['--add-opens=java.base/java.util.stream=ALL-UNNAMED']
  630. jvmArgs = jvmArgs + ['--add-opens=java.base/java.lang=ALL-UNNAMED']
  631. }
  632. // By default, local unit tests throw an exception any time the code you are testing tries to access
  633. // Android platform APIs (unless you mock Android dependencies yourself or with a testing
  634. // framework like Mockito). However, you can enable the following property so that the test
  635. // returns either null or zero when accessing platform APIs, rather than throwing an exception.
  636. returnDefaultValues true
  637. }
  638. }
  639. compileOptions {
  640. coreLibraryDesugaringEnabled true
  641. sourceCompatibility JavaVersion.VERSION_11
  642. targetCompatibility JavaVersion.VERSION_11
  643. }
  644. java {
  645. toolchain {
  646. languageVersion.set(JavaLanguageVersion.of(17))
  647. }
  648. }
  649. kotlin {
  650. jvmToolchain(17)
  651. }
  652. androidResources {
  653. noCompress 'png'
  654. }
  655. lint {
  656. // if true, stop the gradle build if errors are found
  657. abortOnError true
  658. // if true, check all issues, including those that are off by default
  659. checkAllWarnings true
  660. // check dependencies
  661. checkDependencies true
  662. // set to true to have all release builds run lint on issues with severity=fatal
  663. // and abort the build (controlled by abortOnError above) if fatal issues are found
  664. checkReleaseBuilds true
  665. // turn off checking the given issue id's
  666. disable 'TypographyFractions', 'TypographyQuotes', 'RtlHardcoded', 'RtlCompat', 'RtlEnabled'
  667. // Set the severity of the given issues to error
  668. error 'Wakelock', 'TextViewEdits', 'ResourceAsColor'
  669. // Set the severity of the given issues to fatal (which means they will be
  670. // checked during release builds (even if the lint target is not included)
  671. fatal 'NewApi', 'InlinedApi'
  672. // Set the severity of the given issues to ignore (same as disabling the check)
  673. ignore 'TypographyQuotes'
  674. ignoreWarnings false
  675. // if true, don't include source code lines in the error output
  676. noLines false
  677. // if true, show all locations for an error, do not truncate lists, etc.
  678. showAll true
  679. // Set the severity of the given issues to warning
  680. warning 'MissingTranslation'
  681. // if true, treat all warnings as errors
  682. warningsAsErrors false
  683. // file to write report to (if not specified, defaults to lint-results.xml)
  684. xmlOutput file('lint-report.xml')
  685. // if true, generate an XML report for use by for example Jenkins
  686. xmlReport true
  687. }
  688. }
  689. dependencies {
  690. configurations.all {
  691. // Prefer modules that are part of this build (multi-project or composite build)
  692. // over external modules
  693. resolutionStrategy.preferProjectModules()
  694. // Alternatively, we can fail eagerly on version conflict to see the conflicts
  695. //resolutionStrategy.failOnVersionConflict()
  696. }
  697. coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
  698. implementation project(':domain')
  699. implementation 'net.zetetic:sqlcipher-android:4.5.7@aar'
  700. implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
  701. implementation 'net.sf.opencsv:opencsv:2.3'
  702. implementation 'net.lingala.zip4j:zip4j:2.11.5'
  703. implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.3'
  704. // commons-io >2.6 requires android 8
  705. implementation 'commons-io:commons-io:2.6'
  706. implementation 'org.apache.commons:commons-text:1.10.0'
  707. implementation "org.slf4j:slf4j-api:$slf4j_version"
  708. implementation 'com.vanniktech:android-image-cropper:4.5.0'
  709. implementation 'com.datatheorem.android.trustkit:trustkit:1.1.5'
  710. implementation 'me.zhanghai.android.fastscroll:library:1.3.0'
  711. implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
  712. implementation 'com.alexvasilkov:gesture-views:2.8.3'
  713. // AndroidX / Jetpack support libraries
  714. implementation "androidx.preference:preference-ktx:1.2.1"
  715. implementation 'androidx.recyclerview:recyclerview:1.3.2'
  716. implementation 'androidx.palette:palette-ktx:1.0.0'
  717. implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
  718. implementation 'androidx.core:core-ktx:1.13.1'
  719. implementation 'androidx.appcompat:appcompat:1.7.0'
  720. implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
  721. implementation 'androidx.biometric:biometric:1.1.0'
  722. implementation 'androidx.work:work-runtime-ktx:2.9.0'
  723. implementation 'androidx.fragment:fragment-ktx:1.8.0'
  724. implementation 'androidx.activity:activity-ktx:1.9.0'
  725. implementation 'androidx.sqlite:sqlite:2.2.2'
  726. implementation "androidx.concurrent:concurrent-futures:1.2.0"
  727. implementation "androidx.camera:camera-camera2:1.3.4"
  728. implementation "androidx.camera:camera-lifecycle:1.3.4"
  729. implementation "androidx.camera:camera-view:1.3.4"
  730. implementation 'androidx.camera:camera-video:1.3.4'
  731. implementation "androidx.media:media:1.7.0"
  732. implementation 'androidx.media3:media3-exoplayer:1.3.1'
  733. implementation 'androidx.media3:media3-ui:1.3.1'
  734. implementation "androidx.media3:media3-session:1.3.1"
  735. implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.2"
  736. implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.8.2"
  737. implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.8.2"
  738. implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.2"
  739. implementation "androidx.lifecycle:lifecycle-service:2.8.2"
  740. implementation "androidx.lifecycle:lifecycle-process:2.8.2"
  741. implementation "androidx.lifecycle:lifecycle-common-java8:2.8.2"
  742. implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
  743. implementation "androidx.paging:paging-runtime-ktx:3.3.0"
  744. implementation "androidx.sharetarget:sharetarget:1.2.0"
  745. implementation 'androidx.room:room-runtime:2.6.1'
  746. implementation 'androidx.window:window:1.3.0'
  747. kapt 'androidx.room:room-compiler:2.6.1'
  748. implementation 'org.bouncycastle:bcprov-jdk15to18:1.78.1'
  749. implementation 'com.google.android.material:material:1.10.0' // last version before switch to tonal system: https://github.com/material-components/material-components-android/releases/tag/1.11.0
  750. implementation 'com.google.zxing:core:3.3.3' // zxing 3.4 crashes on API < 24
  751. implementation 'com.googlecode.libphonenumber:libphonenumber:8.13.39' // make sure to update this in domain's build.gradle as well
  752. // webclient dependencies
  753. implementation 'org.msgpack:msgpack-core:0.8.24!!'
  754. implementation 'com.fasterxml.jackson.core:jackson-core:2.12.5!!'
  755. implementation 'com.neovisionaries:nv-websocket-client:2.9'
  756. // Backport of Streams and CompletableFuture. Remove once API level 24 is supported.
  757. implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.4'
  758. implementation('org.saltyrtc:saltyrtc-client:0.14.2') {
  759. exclude group: 'org.json'
  760. }
  761. implementation 'org.saltyrtc:chunked-dc:1.0.1'
  762. implementation 'ch.threema:webrtc-android:123.0.0'
  763. implementation('org.saltyrtc:saltyrtc-task-webrtc:0.18.1') {
  764. exclude module: 'saltyrtc-client'
  765. }
  766. // Glide components
  767. // Glide 4.15+ does not work on API 21
  768. implementation 'com.github.bumptech.glide:glide:4.16.0'
  769. kapt 'com.github.bumptech.glide:compiler:4.16.0'
  770. annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
  771. // Kotlin
  772. implementation 'androidx.core:core-ktx:1.13.1'
  773. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  774. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
  775. implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1"
  776. testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
  777. androidTestImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
  778. // use leak canary in debug builds
  779. if (!project.hasProperty("noLeakCanary")) {
  780. debugImplementation('com.squareup.leakcanary:leakcanary-android:2.13')
  781. }
  782. // test dependencies
  783. testImplementation "junit:junit:$junit_version"
  784. testImplementation(testFixtures(project(":domain")))
  785. // custom test helpers, shared between unit test and android tests
  786. testImplementation(project(":test-helpers"))
  787. androidTestImplementation(project(":test-helpers"))
  788. // use powermock instead of mockito. it support mocking static classes.
  789. def mockitoVersion = '2.0.9'
  790. testImplementation "org.powermock:powermock-api-mockito2:${mockitoVersion}"
  791. testImplementation "org.powermock:powermock-module-junit4-rule-agent:${mockitoVersion}"
  792. testImplementation "org.powermock:powermock-module-junit4-rule:${mockitoVersion}"
  793. testImplementation "org.powermock:powermock-module-junit4:${mockitoVersion}"
  794. // add JSON support to tests without mocking
  795. testImplementation 'org.json:json:20220924'
  796. testImplementation 'com.tngtech.archunit:archunit-junit4:0.18.0'
  797. androidTestImplementation(testFixtures(project(":domain")))
  798. androidTestImplementation 'androidx.test:rules:1.6.0'
  799. androidTestImplementation 'tools.fastlane:screengrab:2.1.1', {
  800. exclude group: 'androidx.annotation', module: 'annotation'
  801. }
  802. androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0', {
  803. exclude group: 'androidx.annotation', module: 'annotation'
  804. }
  805. androidTestImplementation 'androidx.test:runner:1.4.0', {
  806. exclude group: 'androidx.annotation', module: 'annotation'
  807. }
  808. androidTestImplementation 'androidx.test.ext:junit-ktx:1.2.0'
  809. androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0', {
  810. exclude group: 'androidx.annotation', module: 'annotation'
  811. exclude group: 'androidx.appcompat', module: 'appcompat'
  812. exclude group: 'androidx.legacy', module: 'legacy-support-v4'
  813. exclude group: 'com.google.android.material', module: 'material'
  814. exclude group: 'androidx.recyclerview', module: 'recyclerview'
  815. exclude(group: 'org.checkerframework', module: 'checker')
  816. exclude module: "protobuf-lite"
  817. }
  818. androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0', {
  819. exclude group: 'androidx.annotation', module: 'annotation'
  820. }
  821. androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.3.0'
  822. androidTestImplementation 'androidx.test:core-ktx:1.6.0'
  823. androidTestImplementation "org.mockito:mockito-core:4.8.1"
  824. androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlin_coroutines_version"
  825. // Google Play Services and related libraries
  826. def googleDependencies = [
  827. // Play services
  828. 'com.google.android.gms:play-services-base:18.0.1': [],
  829. // Firebase push
  830. 'com.google.firebase:firebase-messaging:23.1.2': [
  831. [group: 'com.google.firebase', module: 'firebase-core'],
  832. [group: 'com.google.firebase', module: 'firebase-analytics'],
  833. [group: 'com.google.firebase', module: 'firebase-measurement-connector'],
  834. ],
  835. ]
  836. googleDependencies.each {
  837. def dependency = it.key
  838. def excludes = it.value
  839. noneImplementation(dependency) { excludes.each { exclude it } }
  840. store_googleImplementation(dependency) { excludes.each { exclude it } }
  841. store_google_workImplementation(dependency) { excludes.each { exclude it } }
  842. store_threemaImplementation(dependency) { excludes.each { exclude it } }
  843. onpremImplementation(dependency) { excludes.each { exclude it } }
  844. onprem_internalImplementation(dependency) { excludes.each { exclude it } }
  845. greenImplementation(dependency) { excludes.each { exclude it } }
  846. sandbox_workImplementation(dependency) { excludes.each { exclude it } }
  847. blueImplementation(dependency) { excludes.each { exclude it } }
  848. }
  849. // Google Assistant Voice Action verification library
  850. noneImplementation(name: 'libgsaverification-client', ext: 'aar')
  851. store_googleImplementation(name: 'libgsaverification-client', ext: 'aar')
  852. store_google_workImplementation(name: 'libgsaverification-client', ext: 'aar')
  853. onpremImplementation(name: 'libgsaverification-client', ext: 'aar')
  854. onprem_internalImplementation(name: 'libgsaverification-client', ext: 'aar')
  855. store_threemaImplementation(name: 'libgsaverification-client', ext: 'aar')
  856. greenImplementation(name: 'libgsaverification-client', ext: 'aar')
  857. sandbox_workImplementation(name: 'libgsaverification-client', ext: 'aar')
  858. blueImplementation(name: 'libgsaverification-client', ext: 'aar')
  859. // Maplibre (may have transitive dependencies on Google location services)
  860. def maplibreDependency = 'org.maplibre.gl:android-sdk:11.0.1'
  861. noneImplementation maplibreDependency
  862. store_googleImplementation maplibreDependency
  863. store_google_workImplementation maplibreDependency
  864. store_threemaImplementation maplibreDependency
  865. libreImplementation maplibreDependency, { exclude group: 'com.google.android.gms' }
  866. onpremImplementation maplibreDependency
  867. onprem_internalImplementation maplibreDependency
  868. greenImplementation maplibreDependency
  869. sandbox_workImplementation maplibreDependency
  870. blueImplementation maplibreDependency
  871. hmsImplementation maplibreDependency
  872. hms_workImplementation maplibreDependency
  873. // Huawei related libraries (only for hms* build variants)
  874. def huaweiDependencies = [
  875. // HMS push
  876. 'com.huawei.hms:push:6.3.0.304': [
  877. // Exclude agconnect dependency, we'll replace it with the vendored version below
  878. [group: 'com.huawei.agconnect'],
  879. ],
  880. ]
  881. huaweiDependencies.each {
  882. def dependency = it.key
  883. def excludes = it.value
  884. hmsImplementation(dependency) { excludes.each { exclude it } }
  885. hms_workImplementation(dependency) { excludes.each { exclude it } }
  886. }
  887. hmsImplementation(name: 'agconnect-core-1.9.1.301', ext: 'aar')
  888. hms_workImplementation(name: 'agconnect-core-1.9.1.301', ext: 'aar')
  889. }
  890. tasks.withType(KaptGenerateStubs).configureEach {
  891. kotlinOptions {
  892. jvmTarget = JavaVersion.VERSION_11.toString()
  893. }
  894. }
  895. sonarqube {
  896. properties {
  897. property "sonar.sources", "src/main/, ../scripts/, ../scripts-internal/"
  898. property "sonar.exclusions", "src/main/java/ch/threema/localcrypto/**, src/test/java/ch/threema/localcrypto/**"
  899. property "sonar.tests", "src/test/"
  900. property "sonar.sourceEncoding", "UTF-8"
  901. property "sonar.verbose", "true"
  902. property 'sonar.projectKey', 'android-client'
  903. property 'sonar.projectName', 'Threema for Android'
  904. }
  905. }
  906. // Set up Gradle tasks to fetch screenshots on UI test failures
  907. // See https://medium.com/stepstone-tech/how-to-capture-screenshots-for-failed-ui-tests-9927eea6e1e4
  908. def reportsDirectory = "$buildDir/reports/androidTests/connected"
  909. def screenshotsDirectory = "/sdcard/testfailures/screenshots/"
  910. def clearScreenshotsTask = task('clearScreenshots', type: Exec) {
  911. executable "${android.getAdbExe().toString()}"
  912. args 'shell', 'rm', '-r', screenshotsDirectory
  913. }
  914. def createScreenshotsDirectoryTask = task('createScreenshotsDirectory', type: Exec, group: 'reporting') {
  915. executable "${android.getAdbExe().toString()}"
  916. args 'shell', 'mkdir', '-p', screenshotsDirectory
  917. }
  918. def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') {
  919. executable "${android.getAdbExe().toString()}"
  920. args 'pull', screenshotsDirectory + '.', reportsDirectory
  921. finalizedBy {
  922. clearScreenshotsTask
  923. }
  924. dependsOn {
  925. createScreenshotsDirectoryTask
  926. }
  927. doFirst {
  928. new File(reportsDirectory).mkdirs()
  929. }
  930. }
  931. tasks.whenTaskAdded { task ->
  932. if (task.name == 'connectedDebugAndroidTest') {
  933. task.finalizedBy {
  934. fetchScreenshotsTask
  935. }
  936. }
  937. }