build.gradle 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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.gami"
  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. manifestPlaceholders = [
  80. fbAppId : "",
  81. fbClientToken : "",
  82. deepLinkScheme : "gami",
  83. deepLinkHost : "app",
  84. httpDeepLinkHost: "gami.vip"
  85. ]
  86. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', (isOfficial ? 'proguard-log-empty.pro' : 'proguard-log.pro')
  87. buildConfigField("boolean", "OFFICIAL", project.OFFICIAL)
  88. buildConfigField("boolean", "IS_RELEASE", hookConfigByLocalProperties("IS_RELEASE", IS_RELEASE))
  89. buildConfigField("String", "HTTPS_WEB_HOST", '"https://web.gami.vip"')
  90. buildConfigField("String", "QTT_APP_KEY", '"baa9f1307e2e8ee02742d960828b5c50"')
  91. buildConfigField("String", "HTTP_DEEP_LINK_HOST", '"web.gami.vip"')
  92. buildConfigField("String", "HTTP_DEBUG_DEEP_LINK_HOST", '"test-web.gami.vip"')
  93. buildConfigField("String", "DEEP_LINK_SCHEME", '"gami"')
  94. buildConfigField("String", "DEEP_LINK_HOST", '"app"')
  95. buildConfigField("String", "UTM_FACEBOOK_KEY", '"c4ea5534613d8b3cdcd5b80097989f9eb2414138aa8e49ddfbc458cd5e50f1a6"')
  96. //trtc
  97. buildConfigField("Integer", "TRTC_APP_ID", "80000456")
  98. buildConfigField("String", "TRTC_SECRET_KEY", '"08bc08906522cf1e5d3269282afe0e74f0ea7c240e652f94c836f91ad7e5295b"')
  99. //trtc debug
  100. buildConfigField("Integer", "TRTC_APP_ID_DEBUG", "20030346")
  101. buildConfigField("String", "TRTC_SECRET_KEY_DEBUG", '"a063a1a88b743dacba7f969b70e0b3aec161be06f1326a3913032c5632ed28f9"')
  102. //官方会话ID
  103. buildConfigField("String", "OFFICIAL_UID", "\"${OFFICIAL_UID}\"")
  104. buildConfigField("String", "OFFICIAL_CONVERSATION_ID", "\"${OFFICIAL_CONVERSATION_ID}\"")
  105. //sign key(业务登录)
  106. buildConfigField("String", "SIGN_KEY", '"abc|abc|edg|9527|1234"')
  107. buildConfigField("String", "SIGN_KEY_DEBUG", '"abc|abc|edg|9527|1234"')
  108. }
  109. signingConfigs {
  110. debug {
  111. keyAlias "gami"
  112. keyPassword "gami654321"
  113. storePassword "gami654321"
  114. storeFile file('../keystore/debug/gami-debug.jks')
  115. }
  116. release {
  117. keyAlias "gami"
  118. keyPassword "gami654321"
  119. storePassword "gami654321"
  120. storeFile file("../keystore/release/gami.jks")
  121. }
  122. }
  123. buildTypes {
  124. debug {
  125. minifyEnabled false
  126. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  127. signingConfig signingConfigs.debug
  128. firebaseCrashlytics {
  129. mappingFileUploadEnabled false
  130. }
  131. applicationIdSuffix = '.debug'
  132. manifestPlaceholders = [
  133. appName : "@string/app_name",
  134. appIcon : "@drawable/ic_launcher"
  135. ]
  136. }
  137. release {
  138. debuggable false
  139. minifyEnabled false
  140. signingConfig signingConfigs.release
  141. manifestPlaceholders = [
  142. appName : "@string/app_name",
  143. appIcon : "@drawable/ic_launcher"
  144. ]
  145. firebaseCrashlytics {
  146. mappingFileUploadEnabled false
  147. nativeSymbolUploadEnabled false
  148. // mappingFileUploadEnabled !isOfficial
  149. // nativeSymbolUploadEnabled !isOfficial
  150. // strippedNativeLibsDir 'build/intermediates/stripped_native_libs/release/out/lib'
  151. // unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
  152. }
  153. }
  154. }
  155. compileOptions {
  156. sourceCompatibility JavaVersion.VERSION_17
  157. targetCompatibility JavaVersion.VERSION_17
  158. coreLibraryDesugaringEnabled true
  159. }
  160. compileOptions {
  161. sourceCompatibility JavaVersion.VERSION_17
  162. targetCompatibility JavaVersion.VERSION_17
  163. }
  164. kotlinOptions {
  165. jvmTarget = JavaVersion.VERSION_17.majorVersion
  166. }
  167. bundle {
  168. language {
  169. enableSplit = false
  170. }
  171. density {
  172. enableSplit = false
  173. }
  174. abi {
  175. enableSplit = true
  176. }
  177. }
  178. sourceSets {
  179. main {
  180. jniLibs {
  181. srcDir 'libs'
  182. }
  183. }
  184. }
  185. packagingOptions {
  186. exclude '**/*.kotlin_*'
  187. exclude '**/values-*/strings.xml'
  188. pickFirst('lib/armeabi-v7a/libc++_shared.so')
  189. pickFirst('lib/arm64-v8a/libc++_shared.so')
  190. pickFirst('lib/x86/libc++_shared.so')
  191. pickFirst('lib/x86_64/libc++_shared.so')
  192. }
  193. dynamicFeatures = [
  194. ':module:account',
  195. ':module:profile',
  196. ':module:im',
  197. ':module:playmate',
  198. ':module:activity',
  199. ':module:setting',
  200. ':module:order',
  201. ':module:wallet',
  202. ':module:share',
  203. ':module:image',
  204. ':module:joinus',
  205. ':module:call',
  206. ]
  207. buildFeatures {
  208. viewBinding true
  209. buildConfig true
  210. }
  211. configurations.configureEach {
  212. exclude group: 'com.facebook.fresco', module: 'drawee'
  213. exclude group: 'com.facebook.fresco', module: 'ui-core'
  214. }
  215. lintOptions {
  216. checkReleaseBuilds false
  217. abortOnError false
  218. disable 'Instantiatable'
  219. }
  220. android.applicationVariants.all { variant ->
  221. def variantNameCap = variant.name.capitalize()
  222. def taskName = "sign${variantNameCap}Bundle"
  223. def variantName = variant.name
  224. def flavorName = variant.flavorName
  225. def buildTypeName = variant.buildType.name
  226. tasks.named(taskName).configure { task ->
  227. def file = task.finalBundleFile.get().asFile
  228. def projectName = rootProject.name
  229. def versionCode = variant.versionCode
  230. def versionName = variant.versionName
  231. def timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())
  232. // 构造文件名:projectName-flavor-buildType-versionCode-versionName-timestamp.aab
  233. def nameParts = []
  234. nameParts << "app"
  235. nameParts << projectName
  236. if (flavorName) {
  237. nameParts << flavorName
  238. }
  239. nameParts << buildTypeName
  240. nameParts << "v${versionName}"
  241. nameParts << "(${versionCode})"
  242. nameParts << timestamp
  243. def finalFileName = "${nameParts.join('-')}.aab"
  244. def finalFile = new File(file.parentFile, finalFileName)
  245. task.finalBundleFile.set(finalFile)
  246. }
  247. }
  248. }
  249. gradle.taskGraph.addTaskExecutionListener(new TaskExecutionListener() {
  250. @Override
  251. void beforeExecute(Task task) {
  252. }
  253. @Override
  254. void afterExecute(Task task, TaskState taskState) {
  255. if (task.name.equalsIgnoreCase("bundleDebug")
  256. || task.name.equalsIgnoreCase("bundleRelease")) {
  257. copy {
  258. from 'build/intermediates/intermediary_bundle/'
  259. into 'build/outputs/bundle/'
  260. duplicatesStrategy DuplicatesStrategy.FAIL
  261. }
  262. println("afterExecute " + task.name)
  263. def aabDir = project.getBuildDir().absolutePath + '/outputs/bundle'
  264. fileTree(dir: aabDir, include: '*/*.aab').each { File file ->
  265. println(file.absolutePath)
  266. def cmd = []
  267. cmd << "java"
  268. cmd << "-jar"
  269. cmd << "${project.rootDir}/tool/bundletool.jar"
  270. cmd << "build-apks"
  271. cmd << "--bundle=" + file.absolutePath
  272. cmd << "--output=" + file.parent + File.separator + file.name.replace(".aab", "-split.apks")
  273. cmd << "--overwrite"
  274. cmd << "--mode=universal"
  275. if (task.name.equalsIgnoreCase("bundleDebug")) {
  276. cmd << "--ks=" + android.signingConfigs.debug.storeFile
  277. cmd << "--ks-pass=pass:" + android.signingConfigs.debug.storePassword
  278. cmd << "--ks-key-alias=" + android.signingConfigs.debug.keyAlias
  279. cmd << "--key-pass=pass:" + android.signingConfigs.debug.keyPassword
  280. } else {
  281. def keystoreProperties = new Properties()
  282. keystoreProperties.load(new FileInputStream(rootProject.file('keystore.properties')))
  283. cmd << "--ks=" + keystoreProperties.storeFile
  284. cmd << "--ks-pass=pass:" + keystoreProperties.storePassword
  285. cmd << "--ks-key-alias=" + keystoreProperties.keyAlias
  286. cmd << "--key-pass=pass:" + keystoreProperties.keyPassword
  287. }
  288. exec {
  289. commandLine cmd
  290. }
  291. }
  292. println("after build apks")
  293. }
  294. }
  295. })
  296. configurations.configureEach {
  297. resolutionStrategy {
  298. // 方式1:强制指定所有 gson 依赖使用统一版本
  299. // force 'com.google.code.gson:gson:2.8.6'
  300. // // 方式2:遇到版本冲突时选择指定的版本
  301. eachDependency { DependencyResolveDetails details ->
  302. if (details.requested.group == 'com.google.code.gson' &&
  303. details.requested.name == 'gson') {
  304. details.useVersion "2.8.6"
  305. }
  306. }
  307. }
  308. }
  309. dependencies {
  310. api fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
  311. //kotlin
  312. implementation libs.kotlin.stdlib
  313. coreLibraryDesugaring libs.desugar.jdk.libs
  314. //androidx
  315. api libs.androidx.core.ktx
  316. api libs.androidx.appcompat
  317. api libs.androidx.constraint.layout
  318. api libs.androidx.activity
  319. api libs.androidx.fragment.ktx
  320. api libs.androidx.viewpager2
  321. api libs.androidx.lifecycle.livedata.ktx
  322. api libs.androidx.lifecycle.viewmodel.ktx
  323. api libs.androidx.exifinterface
  324. implementation libs.androidx.multidex
  325. implementation libs.androidx.vectordrawable
  326. implementation libs.androidx.work.manager
  327. api libs.androidx.room.runtime
  328. api libs.androidx.room.ktx
  329. api libs.flexbox
  330. kapt libs.androidx.room.compiler
  331. implementation libs.androidx.camera.core
  332. implementation libs.androidx.camera.camera2
  333. implementation libs.androidx.camera.lifecycle
  334. implementation libs.androidx.camera.video
  335. implementation libs.androidx.camera.view
  336. api libs.androidx.webkit
  337. //android
  338. implementation libs.android.material
  339. implementation libs.android.install.referrer
  340. //google play core
  341. implementation libs.play.feature.delivery
  342. implementation libs.play.feature.delivery.ktx
  343. implementation libs.play.app.update
  344. implementation libs.play.app.update.ktx
  345. //facebook
  346. implementation libs.facebook.android.sdk
  347. //appsflyer
  348. implementation libs.appsflyer
  349. //java
  350. implementation libs.rxjava
  351. //channel
  352. implementation libs.tencent.vasdolly.helper
  353. //firebase
  354. implementation platform(libs.firebase.bom)
  355. implementation libs.firebase.analytics
  356. implementation libs.firebase.crashlytics
  357. implementation libs.firebase.crashlytics.ndk
  358. implementation libs.firebase.dynamic.link
  359. implementation libs.firebase.messaging
  360. //gson
  361. implementation libs.gson
  362. //other
  363. api libs.smart.refresh.layout.kernel
  364. api libs.smart.refresh.header.material
  365. api libs.smart.refresh.footer.classics
  366. api libs.media3.exoplayer
  367. api libs.media3.exoplayer.dash
  368. api libs.media3.ui
  369. // media3 v1.4.1 guava 单独设置, 待media3更新后移除
  370. implementation libs.guava
  371. api libs.video.processor
  372. api libs.payermax
  373. api libs.rxjava
  374. //image
  375. api libs.compressor
  376. //tencent rtc
  377. // api libs.tencent.tui.core
  378. //frame
  379. api platform(libs.frame.bom)
  380. // api libs.frame.tcturing
  381. api libs.frame.animplayer
  382. api libs.frame.drawee
  383. api libs.frame.image
  384. api libs.frame.mvvm
  385. api libs.frame.util
  386. api libs.frame.zero
  387. api libs.frame.base
  388. api libs.frame.network
  389. // api project(":frame:network")
  390. api libs.frame.retrofit
  391. api libs.frame.oss
  392. api libs.frame.download
  393. api libs.frame.sound
  394. api libs.frame.game
  395. api libs.frame.autosize
  396. api libs.frame.spi
  397. api libs.frame.data
  398. api libs.frame.aab
  399. api libs.frame.coroutine
  400. api libs.frame.storage
  401. api libs.frame.log
  402. api libs.frame.statistics
  403. // api project(":frame:statistics")
  404. api libs.frame.googleservice
  405. //api project(":frame:googleservice")
  406. api libs.frame.deviceid
  407. api libs.frame.security
  408. api libs.frame.guide
  409. api libs.frame.effect
  410. //api project(":frame:effect")
  411. api libs.frame.svga
  412. api libs.frame.debug
  413. api project(":frame:room")
  414. api project(":frame:oss")
  415. api libs.frame.startup
  416. api libs.frame.locale
  417. //api libs.frame.push
  418. api libs.frame.media
  419. api libs.frame.share
  420. api libs.frame.dot
  421. api libs.frame.crash
  422. api libs.frame.apm
  423. api libs.frame.audio
  424. api libs.frame.router.annotation
  425. api libs.frame.router.api
  426. kapt libs.frame.router.compiler
  427. implementation libs.toolargetool
  428. annotationProcessor libs.auto.service
  429. implementation(libs.rangeseekbar)
  430. implementation libs.frame.zxing
  431. implementation libs.pinyin
  432. api libs.tencent.tui.core
  433. api libs.tencent.uikit.common
  434. api project(":timcommon")
  435. api project(":tuichat")
  436. implementation project(":tuicontact")
  437. implementation project(":tuiconversation")
  438. api libs.tencent.imsdk
  439. api 'com.google.auto.service:auto-service-annotations:1.1.1'
  440. //implementation project(":tuiroomkit")
  441. api libs.tencent.timpush
  442. api libs.tencent.timpush.fcm
  443. // debugApi "com.tuzhenlei:crashhandler:1.0.1"
  444. // debugApi 'cat.ereza:customactivityoncrash:2.3.0'
  445. // debugImplementation "io.github.yvescheung:Uinspector:2.0.20"
  446. // debugImplementation "io.github.yvescheung:Uinspector-optional-viewmodel:2.0.20"
  447. // debugImplementation "io.github.yvescheung:Uinspector-optional-fresco:2.0.20"
  448. // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
  449. //test
  450. testImplementation libs.junit
  451. androidTestImplementation libs.androidx.junit
  452. androidTestImplementation libs.androidx.espresso.core
  453. if (isEnableTrace) {
  454. implementation(libs.frame.trace.api)
  455. }
  456. api libs.flexbox
  457. }
  458. dependencyGuard {
  459. configuration("releaseRuntimeClasspath")
  460. }