build.gradle 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  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. //trtc debug
  99. buildConfigField("Integer", "TRTC_APP_ID_DEBUG", "20034873")
  100. //官方会话ID
  101. buildConfigField("String", "OFFICIAL_UID", "\"${OFFICIAL_UID}\"")
  102. buildConfigField("String", "OFFICIAL_CONVERSATION_ID", "\"${OFFICIAL_CONVERSATION_ID}\"")
  103. //sign key(业务登录)
  104. buildConfigField("String", "SIGN_KEY", '"abc|abc|edg|9527|1234"')
  105. buildConfigField("String", "SIGN_KEY_DEBUG", '"abc|abc|edg|9527|1234"')
  106. //Adjust
  107. buildConfigField("String", "ADJUST_TOKEN", '"fbze46mdkxds"')
  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. ':module:room',
  207. ':module:gift',
  208. ]
  209. buildFeatures {
  210. viewBinding true
  211. buildConfig true
  212. }
  213. configurations.configureEach {
  214. exclude group: 'com.facebook.fresco', module: 'drawee'
  215. exclude group: 'com.facebook.fresco', module: 'ui-core'
  216. }
  217. lintOptions {
  218. checkReleaseBuilds false
  219. abortOnError false
  220. disable 'Instantiatable'
  221. }
  222. android.applicationVariants.all { variant ->
  223. def variantNameCap = variant.name.capitalize()
  224. def taskName = "sign${variantNameCap}Bundle"
  225. def variantName = variant.name
  226. def flavorName = variant.flavorName
  227. def buildTypeName = variant.buildType.name
  228. tasks.named(taskName).configure { task ->
  229. def file = task.finalBundleFile.get().asFile
  230. def projectName = rootProject.name
  231. def versionCode = variant.versionCode
  232. def versionName = variant.versionName
  233. def timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())
  234. // 构造文件名:projectName-flavor-buildType-versionCode-versionName-timestamp.aab
  235. def nameParts = []
  236. nameParts << "app"
  237. nameParts << projectName
  238. if (flavorName) {
  239. nameParts << flavorName
  240. }
  241. nameParts << buildTypeName
  242. nameParts << "v${versionName}"
  243. nameParts << "(${versionCode})"
  244. nameParts << timestamp
  245. def finalFileName = "${nameParts.join('-')}.aab"
  246. def finalFile = new File(file.parentFile, finalFileName)
  247. task.finalBundleFile.set(finalFile)
  248. }
  249. }
  250. }
  251. gradle.taskGraph.addTaskExecutionListener(new TaskExecutionListener() {
  252. @Override
  253. void beforeExecute(Task task) {
  254. }
  255. @Override
  256. void afterExecute(Task task, TaskState taskState) {
  257. if (task.name.equalsIgnoreCase("bundleDebug")
  258. || task.name.equalsIgnoreCase("bundleRelease")) {
  259. copy {
  260. from 'build/intermediates/intermediary_bundle/'
  261. into 'build/outputs/bundle/'
  262. duplicatesStrategy DuplicatesStrategy.FAIL
  263. }
  264. println("afterExecute " + task.name)
  265. def aabDir = project.getBuildDir().absolutePath + '/outputs/bundle'
  266. def archiveDir = rootProject.file("archive")
  267. def buildNumber = System.getenv("BUILD_NUMBER") ?: "local"
  268. def targetDir = new File(archiveDir, buildNumber)
  269. fileTree(dir: aabDir, include: '*/*.aab').each { File file ->
  270. println(file.absolutePath)
  271. def apksPath = file.parent + File.separator + file.name.replace(".aab", "-split.apks")
  272. def cmd = []
  273. cmd << "java"
  274. cmd << "-jar"
  275. cmd << "${project.rootDir}/tool/bundletool.jar"
  276. cmd << "build-apks"
  277. cmd << "--bundle=" + file.absolutePath
  278. cmd << "--output=" + apksPath
  279. cmd << "--overwrite"
  280. cmd << "--mode=universal"
  281. if (task.name.equalsIgnoreCase("bundleDebug")) {
  282. cmd << "--ks=" + android.signingConfigs.debug.storeFile
  283. cmd << "--ks-pass=pass:" + android.signingConfigs.debug.storePassword
  284. cmd << "--ks-key-alias=" + android.signingConfigs.debug.keyAlias
  285. cmd << "--key-pass=pass:" + android.signingConfigs.debug.keyPassword
  286. } else {
  287. def keystoreProperties = new Properties()
  288. keystoreProperties.load(new FileInputStream(rootProject.file('keystore.properties')))
  289. cmd << "--ks=" + keystoreProperties.storeFile
  290. cmd << "--ks-pass=pass:" + keystoreProperties.storePassword
  291. cmd << "--ks-key-alias=" + keystoreProperties.keyAlias
  292. cmd << "--key-pass=pass:" + keystoreProperties.keyPassword
  293. }
  294. exec {
  295. commandLine cmd
  296. }
  297. println("extracting apks: " + apksPath)
  298. def outputDir = file.parent + File.separator + file.name.replace(".aab", "-extracted")
  299. project.copy {
  300. from project.zipTree(apksPath)
  301. into outputDir
  302. }
  303. // 1. 重命名 universal.apk 为 apks 的名称 (xxx-split.apk)
  304. def apksFile = new File(apksPath)
  305. def finalApkName = apksFile.name.replace(".apks", ".apk")
  306. def finalApkFile = new File(file.parentFile, finalApkName)
  307. def extractedApk = new File(outputDir, "universal.apk")
  308. if (extractedApk.exists()) {
  309. extractedApk.renameTo(finalApkFile)
  310. }
  311. // 2. 复制 APK 和 AAB 到 archive 目录下
  312. println("archiving to: " + targetDir.absolutePath)
  313. project.copy {
  314. from file
  315. from finalApkFile
  316. into targetDir
  317. }
  318. }
  319. println("after build, extract and archive")
  320. }
  321. }
  322. })
  323. configurations.configureEach {
  324. resolutionStrategy {
  325. // 方式1:强制指定所有 gson 依赖使用统一版本
  326. // force 'com.google.code.gson:gson:2.8.6'
  327. // // 方式2:遇到版本冲突时选择指定的版本
  328. eachDependency { DependencyResolveDetails details ->
  329. if (details.requested.group == 'com.google.code.gson' &&
  330. details.requested.name == 'gson') {
  331. details.useVersion "2.8.6"
  332. }
  333. }
  334. }
  335. }
  336. dependencies {
  337. api fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
  338. //kotlin
  339. implementation libs.kotlin.stdlib
  340. coreLibraryDesugaring libs.desugar.jdk.libs
  341. //androidx
  342. api libs.androidx.core.ktx
  343. api libs.androidx.appcompat
  344. api libs.androidx.constraint.layout
  345. api libs.androidx.activity
  346. api libs.androidx.fragment.ktx
  347. api libs.androidx.viewpager2
  348. api libs.androidx.lifecycle.livedata.ktx
  349. api libs.androidx.lifecycle.viewmodel.ktx
  350. api libs.androidx.exifinterface
  351. implementation libs.androidx.multidex
  352. implementation libs.androidx.vectordrawable
  353. implementation libs.androidx.work.manager
  354. api libs.androidx.room.runtime
  355. api libs.androidx.room.ktx
  356. api libs.flexbox
  357. kapt libs.androidx.room.compiler
  358. implementation libs.androidx.camera.core
  359. implementation libs.androidx.camera.camera2
  360. implementation libs.androidx.camera.lifecycle
  361. implementation libs.androidx.camera.video
  362. implementation libs.androidx.camera.view
  363. api libs.androidx.webkit
  364. //android
  365. implementation libs.android.material
  366. implementation libs.android.install.referrer
  367. //google play core
  368. implementation libs.play.feature.delivery
  369. implementation libs.play.feature.delivery.ktx
  370. implementation libs.play.app.update
  371. implementation libs.play.app.update.ktx
  372. //facebook
  373. implementation libs.facebook.android.sdk
  374. //adjust
  375. implementation libs.adjust.android
  376. implementation libs.adjust.android.webbridge
  377. implementation libs.gms.play.services.ads.identifier
  378. //java
  379. implementation libs.rxjava
  380. //channel
  381. implementation libs.tencent.vasdolly.helper
  382. //firebase
  383. implementation platform(libs.firebase.bom)
  384. implementation libs.firebase.analytics
  385. implementation libs.firebase.crashlytics
  386. implementation libs.firebase.crashlytics.ndk
  387. implementation libs.firebase.dynamic.link
  388. implementation libs.firebase.messaging
  389. //gson
  390. implementation libs.gson
  391. //other
  392. api libs.smart.refresh.layout.kernel
  393. api libs.smart.refresh.header.material
  394. api libs.smart.refresh.footer.classics
  395. api libs.media3.exoplayer
  396. api libs.media3.exoplayer.dash
  397. api libs.media3.ui
  398. // media3 v1.4.1 guava 单独设置, 待media3更新后移除
  399. implementation libs.guava
  400. api libs.video.processor
  401. api libs.payermax
  402. api libs.rxjava
  403. //image
  404. api libs.compressor
  405. //tencent rtc
  406. // api libs.tencent.tui.core
  407. //frame
  408. api platform(libs.frame.bom)
  409. // api libs.frame.tcturing
  410. api libs.frame.animplayer
  411. api libs.frame.drawee
  412. api libs.frame.image
  413. api libs.frame.mvvm
  414. api libs.frame.util
  415. api libs.frame.zero
  416. api libs.frame.base
  417. api libs.frame.network
  418. // api project(":frame:network")
  419. api libs.frame.retrofit
  420. api libs.frame.oss
  421. api libs.frame.download
  422. api libs.frame.sound
  423. api libs.frame.game
  424. api libs.frame.autosize
  425. api libs.frame.spi
  426. api libs.frame.data
  427. api libs.frame.aab
  428. api libs.frame.coroutine
  429. api libs.frame.storage
  430. api libs.frame.log
  431. api libs.frame.statistics
  432. // api project(":frame:statistics")
  433. api libs.frame.googleservice
  434. //api project(":frame:googleservice")
  435. api libs.frame.deviceid
  436. api libs.frame.security
  437. api libs.frame.guide
  438. api libs.frame.effect
  439. //api project(":frame:effect")
  440. api libs.frame.svga
  441. api libs.frame.debug
  442. api project(":frame:room")
  443. api project(":frame:oss")
  444. api libs.frame.startup
  445. api libs.frame.locale
  446. //api libs.frame.push
  447. api libs.frame.media
  448. api libs.frame.share
  449. api libs.frame.dot
  450. api libs.frame.crash
  451. api libs.frame.apm
  452. api libs.frame.audio
  453. api libs.frame.router.annotation
  454. api libs.frame.router.api
  455. kapt libs.frame.router.compiler
  456. implementation libs.toolargetool
  457. annotationProcessor libs.auto.service
  458. implementation(libs.rangeseekbar)
  459. implementation libs.frame.zxing
  460. implementation libs.pinyin
  461. api libs.tencent.tui.core
  462. api libs.tencent.uikit.common
  463. api project(":timcommon")
  464. api project(":tuichat")
  465. implementation project(":tuiconversation")
  466. api libs.tencent.imsdk
  467. api 'com.google.auto.service:auto-service-annotations:1.1.1'
  468. //implementation project(":tuiroomkit")
  469. api libs.tencent.timpush
  470. api libs.tencent.timpush.fcm
  471. api libs.tencent.atomic.x
  472. // debugApi "com.tuzhenlei:crashhandler:1.0.1"
  473. // debugApi 'cat.ereza:customactivityoncrash:2.3.0'
  474. // debugImplementation "io.github.yvescheung:Uinspector:2.0.20"
  475. // debugImplementation "io.github.yvescheung:Uinspector-optional-viewmodel:2.0.20"
  476. // debugImplementation "io.github.yvescheung:Uinspector-optional-fresco:2.0.20"
  477. // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
  478. //test
  479. testImplementation libs.junit
  480. androidTestImplementation libs.androidx.junit
  481. androidTestImplementation libs.androidx.espresso.core
  482. if (isEnableTrace) {
  483. implementation(libs.frame.trace.api)
  484. }
  485. api libs.flexbox
  486. }
  487. dependencyGuard {
  488. configuration("releaseRuntimeClasspath")
  489. }