build.gradle 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. import java.text.SimpleDateFormat
  2. plugins {
  3. id 'com.android.application'
  4. id 'org.jetbrains.kotlin.android'
  5. id 'com.google.gms.google-services'
  6. id 'com.google.firebase.crashlytics'
  7. id 'org.jetbrains.kotlin.kapt'
  8. id 'com.tencent.vasdolly'
  9. id 'kotlin-parcelize'
  10. id("com.dropbox.dependency-guard") version "0.5.0"
  11. }
  12. apply plugin: 'com.wenext.bundle.local.test'
  13. def isEnableTrace = project.hasProperty("ENABLE_TRACE") && project.ENABLE_TRACE.toBoolean()
  14. if (isEnableTrace) {
  15. apply plugin: "LancerTracePlugin"
  16. }
  17. println("isEnableTrace: " + isEnableTrace)
  18. def isOfficial = project.OFFICIAL == "true"
  19. if (!isOfficial) {
  20. apply from: "proguard-log.gradle"
  21. }
  22. println("isOfficial:" + isOfficial)
  23. println("IS_RELEASE:" + project.IS_RELEASE)
  24. //apply from: "aab_res_guard.gradle"
  25. apply from: "zip-audio-to-assets.gradle"
  26. apply from: "dependencyGuard.gradle"
  27. def hookConfigByLocalProperties(String localKey, String defaultValue) {
  28. String config = readLocalProperties(localKey)
  29. if (config != null) {
  30. System.out.println("hookConfigByLocalProperties($localKey) ==> $config")
  31. return config
  32. }
  33. return defaultValue
  34. }
  35. def readLocalProperties(String key) {
  36. File file = rootProject.file('local.properties')
  37. if (file.exists()) {
  38. //加载资源
  39. InputStream inputStream = rootProject.file('local.properties').newDataInputStream();
  40. Properties properties = new Properties()
  41. properties.load(inputStream)
  42. if (properties.containsKey(key)) {
  43. return properties.getProperty(key)
  44. }
  45. }
  46. return null
  47. }
  48. android {
  49. namespace 'com.adealink.weparty'
  50. compileSdk libs.versions.compileSdk.get().toInteger()
  51. defaultConfig {
  52. applicationId "com.jiehe.lanu"
  53. minSdk libs.versions.minSdk.get().toInteger()
  54. targetSdk libs.versions.targetSdk.get().toInteger()
  55. multiDexEnabled true
  56. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  57. resConfigs "zh", "en", "in"
  58. ndk {
  59. abiFilters "armeabi-v7a"
  60. abiFilters "arm64-v8a"
  61. debugSymbolLevel 'FULL'
  62. }
  63. //指定room.schemaLocation生成的文件路径 处理Room 警告 Schema export Error
  64. javaCompileOptions {
  65. annotationProcessorOptions {
  66. arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
  67. }
  68. }
  69. def jvc = project.hasProperty('JKS_VERSION_CODE') ? project.JKS_VERSION_CODE : ""
  70. def jvn = project.hasProperty('JKS_VERSION_NAME') ? project.JKS_VERSION_NAME : ""
  71. def localVC = hookConfigByLocalProperties("VERSION_CODE", VERSION_CODE)
  72. def localVN = hookConfigByLocalProperties("VERSION_NAME", VERSION_NAME)
  73. def vc = jvc != "" ? project.JKS_VERSION_CODE.toInteger() : localVC.toInteger()
  74. def vn = jvn != "" ? project.JKS_VERSION_NAME : localVN
  75. println("version_code = " + vc)
  76. println("version_name = " + vn)
  77. versionCode vc
  78. versionName vn
  79. //TODO: 替换fbAppId
  80. manifestPlaceholders = [
  81. fbAppId : "",
  82. fbClientToken : "",
  83. deepLinkScheme : "partyki",
  84. deepLinkHost : "yoki",
  85. httpDeepLinkHost: "yoki.chat"
  86. ]
  87. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', (isOfficial ? 'proguard-log-empty.pro' : 'proguard-log.pro')
  88. buildConfigField("boolean", "OFFICIAL", project.OFFICIAL)
  89. buildConfigField("boolean", "IS_RELEASE", hookConfigByLocalProperties("IS_RELEASE", IS_RELEASE))
  90. buildConfigField("String", "HTTPS_WEB_HOST", '"https://web.yoki.chat"')
  91. buildConfigField("String", "AUTH_APPLE_PATH", '"/web/yoki-auth/apple"')
  92. buildConfigField("String", "QTT_APP_KEY", '"baa9f1307e2e8ee02742d960828b5c50"')
  93. buildConfigField("String", "HTTP_DEEP_LINK_HOST", '"yoki.chat"')
  94. buildConfigField("String", "DEEP_LINK_SCHEME", '"partyki"')
  95. buildConfigField("String", "DEEP_LINK_HOST", '"yoki"')
  96. buildConfigField("String", "UTM_FACEBOOK_KEY", '"c4ea5534613d8b3cdcd5b80097989f9eb2414138aa8e49ddfbc458cd5e50f1a6"')
  97. // buildConfigField("String", "TIKTOK_CLIENT_KEY", '"aw8fs7e6lnjmfipk"')
  98. // buildConfigField("String", "TIKTOK_REDIRECT_URL", '"https://yoki.chat/applink/login"')
  99. // buildConfigField("String", "AGORA_APP_ID", '"a5233b5e42534b77bbabf2ca8ac95215"')
  100. //trtc
  101. buildConfigField("Integer", "TRTC_APP_ID", "20030346")
  102. buildConfigField("String", "TRTC_SECRET_KEY", '"a063a1a88b743dacba7f969b70e0b3aec161be06f1326a3913032c5632ed28f9"')
  103. //trtc debug
  104. buildConfigField("Integer", "TRTC_APP_ID_DEBUG", "20030346")
  105. buildConfigField("String", "TRTC_SECRET_KEY_DEBUG", '"a063a1a88b743dacba7f969b70e0b3aec161be06f1326a3913032c5632ed28f9"')
  106. //sign key
  107. buildConfigField("String", "SIGN_KEY", '"abc|abc|edg|9527|1234"')
  108. buildConfigField("String", "SIGN_KEY_DEBUG", '"abc|abc|edg|9527|1234"')
  109. }
  110. signingConfigs {
  111. debug {
  112. keyAlias "lanu-debug"
  113. keyPassword "lanu654321"
  114. storePassword "lanu654321"
  115. storeFile file('../keystore/debug/lanu-debug.jks')
  116. }
  117. release {
  118. keyAlias "lanu-release"
  119. keyPassword "lanu654321"
  120. storePassword "lanu654321"
  121. storeFile file("../keystore/release/lanu-release.jks")
  122. }
  123. }
  124. buildTypes {
  125. debug {
  126. minifyEnabled false
  127. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  128. signingConfig signingConfigs.debug
  129. firebaseCrashlytics {
  130. mappingFileUploadEnabled false
  131. }
  132. applicationIdSuffix = '.debug'
  133. }
  134. release {
  135. debuggable false
  136. minifyEnabled true
  137. signingConfig signingConfigs.release
  138. firebaseCrashlytics {
  139. mappingFileUploadEnabled false
  140. nativeSymbolUploadEnabled false
  141. // mappingFileUploadEnabled !isOfficial
  142. // nativeSymbolUploadEnabled !isOfficial
  143. // strippedNativeLibsDir 'build/intermediates/stripped_native_libs/release/out/lib'
  144. // unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
  145. }
  146. }
  147. }
  148. compileOptions {
  149. sourceCompatibility JavaVersion.VERSION_17
  150. targetCompatibility JavaVersion.VERSION_17
  151. coreLibraryDesugaringEnabled true
  152. }
  153. compileOptions {
  154. sourceCompatibility JavaVersion.VERSION_17
  155. targetCompatibility JavaVersion.VERSION_17
  156. }
  157. kotlinOptions {
  158. jvmTarget = JavaVersion.VERSION_17.majorVersion
  159. }
  160. bundle {
  161. language {
  162. enableSplit = false
  163. }
  164. density {
  165. enableSplit = false
  166. }
  167. abi {
  168. enableSplit = true
  169. }
  170. }
  171. sourceSets {
  172. main {
  173. jniLibs {
  174. srcDir 'libs'
  175. }
  176. }
  177. }
  178. packagingOptions {
  179. exclude '**/*.kotlin_*'
  180. pickFirst('lib/armeabi-v7a/libc++_shared.so')
  181. pickFirst('lib/arm64-v8a/libc++_shared.so')
  182. pickFirst('lib/x86/libc++_shared.so')
  183. pickFirst('lib/x86_64/libc++_shared.so')
  184. }
  185. dynamicFeatures = [
  186. ':module:account',
  187. ':module:profile',
  188. ':module:im',
  189. ':module:playmate',
  190. ':module:activity',
  191. ':module:setting',
  192. ':module:order',
  193. ':module:wallet',
  194. ':module:share',
  195. ':module:image',
  196. ]
  197. buildFeatures {
  198. viewBinding true
  199. buildConfig true
  200. }
  201. configurations.configureEach {
  202. exclude group: 'com.facebook.fresco', module: 'drawee'
  203. exclude group: 'com.facebook.fresco', module: 'ui-core'
  204. }
  205. android.applicationVariants.all { variant ->
  206. def variantNameCap = variant.name.capitalize()
  207. def taskName = "sign${variantNameCap}Bundle"
  208. def variantName = variant.name
  209. def flavorName = variant.flavorName
  210. def buildTypeName = variant.buildType.name
  211. tasks.named(taskName).configure { task ->
  212. def file = task.finalBundleFile.get().asFile
  213. def projectName = rootProject.name
  214. def versionCode = variant.versionCode
  215. def versionName = variant.versionName
  216. def timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())
  217. // 构造文件名:projectName-flavor-buildType-versionCode-versionName-timestamp.aab
  218. def nameParts = []
  219. nameParts << "app"
  220. nameParts << projectName
  221. if (flavorName) {
  222. nameParts << flavorName
  223. }
  224. nameParts << buildTypeName
  225. nameParts << "v${versionName}"
  226. nameParts << "(${versionCode})"
  227. nameParts << timestamp
  228. def finalFileName = "${nameParts.join('-')}.aab"
  229. def finalFile = new File(file.parentFile, finalFileName)
  230. task.finalBundleFile.set(finalFile)
  231. }
  232. }
  233. }
  234. gradle.taskGraph.addTaskExecutionListener(new TaskExecutionListener() {
  235. @Override
  236. void beforeExecute(Task task) {
  237. }
  238. @Override
  239. void afterExecute(Task task, TaskState taskState) {
  240. if (task.name.equalsIgnoreCase("bundleDebug")
  241. || task.name.equalsIgnoreCase("bundleRelease")) {
  242. copy {
  243. from 'build/intermediates/intermediary_bundle/'
  244. into 'build/outputs/bundle/'
  245. duplicatesStrategy DuplicatesStrategy.FAIL
  246. }
  247. println("afterExecute " + task.name)
  248. def aabDir = project.getBuildDir().absolutePath + '/outputs/bundle'
  249. fileTree(dir: aabDir, include: '*/*.aab').each { File file ->
  250. println(file.absolutePath)
  251. def cmd = []
  252. cmd << "java"
  253. cmd << "-jar"
  254. cmd << "${project.rootDir}/tool/bundletool.jar"
  255. cmd << "build-apks"
  256. cmd << "--bundle=" + file.absolutePath
  257. cmd << "--output=" + file.parent + File.separator + file.name.replace(".aab", "-split.apks")
  258. cmd << "--overwrite"
  259. cmd << "--mode=universal"
  260. if (task.name.equalsIgnoreCase("bundleDebug")) {
  261. cmd << "--ks=" + android.signingConfigs.debug.storeFile
  262. cmd << "--ks-pass=pass:" + android.signingConfigs.debug.storePassword
  263. cmd << "--ks-key-alias=" + android.signingConfigs.debug.keyAlias
  264. cmd << "--key-pass=pass:" + android.signingConfigs.debug.keyPassword
  265. } else {
  266. def keystoreProperties = new Properties()
  267. keystoreProperties.load(new FileInputStream(rootProject.file('keystore.properties')))
  268. cmd << "--ks=" + keystoreProperties.storeFile
  269. cmd << "--ks-pass=pass:" + keystoreProperties.storePassword
  270. cmd << "--ks-key-alias=" + keystoreProperties.keyAlias
  271. cmd << "--key-pass=pass:" + keystoreProperties.keyPassword
  272. }
  273. exec {
  274. commandLine cmd
  275. }
  276. }
  277. println("after build apks")
  278. }
  279. }
  280. })
  281. configurations.configureEach {
  282. resolutionStrategy {
  283. // 方式1:强制指定所有 gson 依赖使用统一版本
  284. // force 'com.google.code.gson:gson:2.8.6'
  285. // // 方式2:遇到版本冲突时选择指定的版本
  286. eachDependency { DependencyResolveDetails details ->
  287. if (details.requested.group == 'com.google.code.gson' &&
  288. details.requested.name == 'gson') {
  289. details.useVersion "2.8.6"
  290. }
  291. }
  292. }
  293. }
  294. dependencies {
  295. api fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
  296. //kotlin
  297. implementation libs.kotlin.stdlib
  298. coreLibraryDesugaring libs.desugar.jdk.libs
  299. //androidx
  300. api libs.androidx.core.ktx
  301. api libs.androidx.appcompat
  302. api libs.androidx.constraint.layout
  303. api libs.androidx.activity
  304. api libs.androidx.fragment.ktx
  305. api libs.androidx.viewpager2
  306. api libs.androidx.lifecycle.livedata.ktx
  307. api libs.androidx.lifecycle.viewmodel.ktx
  308. api libs.androidx.exifinterface
  309. implementation libs.androidx.multidex
  310. implementation libs.androidx.vectordrawable
  311. implementation libs.androidx.work.manager
  312. api libs.androidx.room.runtime
  313. api libs.androidx.room.ktx
  314. api libs.flexbox
  315. kapt libs.androidx.room.compiler
  316. implementation libs.androidx.camera.core
  317. implementation libs.androidx.camera.camera2
  318. implementation libs.androidx.camera.lifecycle
  319. implementation libs.androidx.camera.video
  320. implementation libs.androidx.camera.view
  321. api libs.androidx.webkit
  322. //android
  323. implementation libs.android.material
  324. implementation libs.android.install.referrer
  325. //google play core
  326. implementation libs.play.feature.delivery
  327. implementation libs.play.feature.delivery.ktx
  328. implementation libs.play.app.update
  329. implementation libs.play.app.update.ktx
  330. //facebook
  331. implementation libs.facebook.android.sdk
  332. //appsflyer
  333. implementation libs.appsflyer
  334. //java
  335. implementation libs.rxjava
  336. //channel
  337. implementation libs.tencent.vasdolly.helper
  338. //firebase
  339. implementation platform(libs.firebase.bom)
  340. implementation libs.firebase.analytics
  341. implementation libs.firebase.crashlytics
  342. implementation libs.firebase.crashlytics.ndk
  343. implementation libs.firebase.dynamic.link
  344. implementation libs.firebase.messaging
  345. //gson
  346. implementation libs.gson
  347. //other
  348. api libs.smart.refresh.layout.kernel
  349. api libs.smart.refresh.header.material
  350. api libs.smart.refresh.footer.classics
  351. api libs.media3.exoplayer
  352. api libs.media3.exoplayer.dash
  353. api libs.media3.ui
  354. // media3 v1.4.1 guava 单独设置, 待media3更新后移除
  355. implementation libs.guava
  356. api libs.video.processor
  357. api libs.payermax
  358. api libs.rxjava
  359. //image
  360. api libs.compressor
  361. //tencent rtc
  362. // api libs.tencent.tui.core
  363. //frame
  364. api platform(libs.frame.bom)
  365. // api libs.frame.tcturing
  366. api libs.frame.animplayer
  367. api libs.frame.drawee
  368. api libs.frame.image
  369. api libs.frame.mvvm
  370. api libs.frame.util
  371. api libs.frame.zero
  372. api libs.frame.base
  373. api libs.frame.network
  374. // api project(":frame:network")
  375. api libs.frame.retrofit
  376. api libs.frame.oss
  377. api libs.frame.download
  378. api libs.frame.sound
  379. api libs.frame.game
  380. api libs.frame.autosize
  381. api libs.frame.spi
  382. api libs.frame.data
  383. api libs.frame.aab
  384. api libs.frame.coroutine
  385. api libs.frame.storage
  386. api libs.frame.log
  387. api libs.frame.statistics
  388. // api project(":frame:statistics")
  389. api libs.frame.googleservice
  390. //api project(":frame:googleservice")
  391. api libs.frame.deviceid
  392. api libs.frame.security
  393. api libs.frame.guide
  394. api libs.frame.effect
  395. //api project(":frame:effect")
  396. api libs.frame.svga
  397. api libs.frame.debug
  398. api project(":frame:room")
  399. api project(":frame:oss")
  400. api libs.frame.startup
  401. api libs.frame.locale
  402. api libs.frame.push
  403. api libs.frame.media
  404. api libs.frame.share
  405. api libs.frame.dot
  406. api libs.frame.crash
  407. api libs.frame.apm
  408. api libs.frame.audio
  409. api libs.frame.router.annotation
  410. api libs.frame.router.api
  411. kapt libs.frame.router.compiler
  412. implementation libs.toolargetool
  413. annotationProcessor libs.auto.service
  414. implementation(libs.rangeseekbar)
  415. implementation project(":tuicore")
  416. implementation project(":timcommon")
  417. implementation project(":tuichat")
  418. implementation project(":tuicontact")
  419. implementation project(":tuiconversation")
  420. implementation project(":tuisearch")
  421. implementation project(":tuicommunity")
  422. implementation project(":tuicustomerserviceplugin")
  423. implementation project(":tuiroomkit")
  424. // debugApi "com.tuzhenlei:crashhandler:1.0.1"
  425. // debugApi 'cat.ereza:customactivityoncrash:2.3.0'
  426. // debugImplementation "io.github.yvescheung:Uinspector:2.0.20"
  427. // debugImplementation "io.github.yvescheung:Uinspector-optional-viewmodel:2.0.20"
  428. // debugImplementation "io.github.yvescheung:Uinspector-optional-fresco:2.0.20"
  429. // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
  430. //test
  431. testImplementation libs.junit
  432. androidTestImplementation libs.androidx.junit
  433. androidTestImplementation libs.androidx.espresso.core
  434. if (isEnableTrace) {
  435. implementation(libs.frame.trace.api)
  436. }
  437. api libs.flexbox
  438. }
  439. dependencyGuard {
  440. configuration("releaseRuntimeClasspath")
  441. }