build.gradle 51 KB

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