build.gradle 51 KB

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