build.gradle 50 KB

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