build.gradle 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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", "ar"
  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 : "623244786994791",
  81. fbClientToken : "d4f871dc66d01eb357146318d6b63a09",
  82. deepLinkScheme : "partyki",
  83. deepLinkHost : "yoki",
  84. httpDeepLinkHost: "yoki.chat"
  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.yoki.chat"')
  90. buildConfigField("String", "AUTH_APPLE_PATH", '"/web/yoki-auth/apple"')
  91. buildConfigField("String", "QTT_APP_KEY", '"baa9f1307e2e8ee02742d960828b5c50"')
  92. buildConfigField("String", "HTTP_DEEP_LINK_HOST", '"yoki.chat"')
  93. buildConfigField("String", "DEEP_LINK_SCHEME", '"partyki"')
  94. buildConfigField("String", "DEEP_LINK_HOST", '"yoki"')
  95. buildConfigField("String", "UTM_FACEBOOK_KEY", '"c4ea5534613d8b3cdcd5b80097989f9eb2414138aa8e49ddfbc458cd5e50f1a6"')
  96. // buildConfigField("String", "TIKTOK_CLIENT_KEY", '"aw8fs7e6lnjmfipk"')
  97. // buildConfigField("String", "TIKTOK_REDIRECT_URL", '"https://yoki.chat/applink/login"')
  98. // buildConfigField("String", "AGORA_APP_ID", '"a5233b5e42534b77bbabf2ca8ac95215"')
  99. //trtc
  100. buildConfigField("Integer", "TRTC_APP_ID", "20030346")
  101. buildConfigField("String", "TRTC_SECRET_KEY", '"a063a1a88b743dacba7f969b70e0b3aec161be06f1326a3913032c5632ed28f9"')
  102. //trtc debug
  103. buildConfigField("Integer", "TRTC_APP_ID_DEBUG", "20030346")
  104. buildConfigField("String", "TRTC_SECRET_KEY_DEBUG", '"a063a1a88b743dacba7f969b70e0b3aec161be06f1326a3913032c5632ed28f9"')
  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 "lanu-debug"
  112. keyPassword "lanu654321"
  113. storePassword "lanu654321"
  114. storeFile file('../keystore/debug/lanu-debug.jks')
  115. }
  116. release {
  117. keyAlias "lanu-release"
  118. keyPassword "lanu654321"
  119. storePassword "lanu654321"
  120. storeFile file("../keystore/release/lanu-release.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. }
  133. release {
  134. debuggable false
  135. minifyEnabled true
  136. signingConfig signingConfigs.release
  137. firebaseCrashlytics {
  138. mappingFileUploadEnabled false
  139. nativeSymbolUploadEnabled false
  140. // mappingFileUploadEnabled !isOfficial
  141. // nativeSymbolUploadEnabled !isOfficial
  142. // strippedNativeLibsDir 'build/intermediates/stripped_native_libs/release/out/lib'
  143. // unstrippedNativeLibsDir 'build/intermediates/merged_native_libs/release/out/lib'
  144. }
  145. }
  146. }
  147. compileOptions {
  148. sourceCompatibility JavaVersion.VERSION_17
  149. targetCompatibility JavaVersion.VERSION_17
  150. coreLibraryDesugaringEnabled true
  151. }
  152. compileOptions {
  153. sourceCompatibility JavaVersion.VERSION_17
  154. targetCompatibility JavaVersion.VERSION_17
  155. }
  156. kotlinOptions {
  157. jvmTarget = JavaVersion.VERSION_17.majorVersion
  158. }
  159. bundle {
  160. language {
  161. enableSplit = false
  162. }
  163. density {
  164. enableSplit = false
  165. }
  166. abi {
  167. enableSplit = true
  168. }
  169. }
  170. sourceSets {
  171. main {
  172. jniLibs {
  173. srcDir 'libs'
  174. }
  175. }
  176. }
  177. packagingOptions {
  178. exclude '**/*.kotlin_*'
  179. pickFirst('lib/armeabi-v7a/libc++_shared.so')
  180. pickFirst('lib/arm64-v8a/libc++_shared.so')
  181. pickFirst('lib/x86/libc++_shared.so')
  182. pickFirst('lib/x86_64/libc++_shared.so')
  183. }
  184. dynamicFeatures = [
  185. ':module:account',
  186. ':module:profile',
  187. ]
  188. buildFeatures {
  189. viewBinding true
  190. buildConfig true
  191. }
  192. configurations.configureEach {
  193. exclude group: 'com.facebook.fresco', module: 'drawee'
  194. exclude group: 'com.facebook.fresco', module: 'ui-core'
  195. }
  196. android.applicationVariants.all { variant ->
  197. def variantNameCap = variant.name.capitalize()
  198. def taskName = "sign${variantNameCap}Bundle"
  199. def variantName = variant.name
  200. def flavorName = variant.flavorName
  201. def buildTypeName = variant.buildType.name
  202. tasks.named(taskName).configure { task ->
  203. def file = task.finalBundleFile.get().asFile
  204. def projectName = rootProject.name
  205. def versionCode = variant.versionCode
  206. def versionName = variant.versionName
  207. def timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date())
  208. // 构造文件名:projectName-flavor-buildType-versionCode-versionName-timestamp.aab
  209. def nameParts = []
  210. nameParts << "app"
  211. nameParts << projectName
  212. if (flavorName) {
  213. nameParts << flavorName
  214. }
  215. nameParts << buildTypeName
  216. nameParts << "v${versionName}"
  217. nameParts << "(${versionCode})"
  218. nameParts << timestamp
  219. def finalFileName = "${nameParts.join('-')}.aab"
  220. def finalFile = new File(file.parentFile, finalFileName)
  221. task.finalBundleFile.set(finalFile)
  222. }
  223. }
  224. }
  225. gradle.taskGraph.addTaskExecutionListener(new TaskExecutionListener() {
  226. @Override
  227. void beforeExecute(Task task) {
  228. }
  229. @Override
  230. void afterExecute(Task task, TaskState taskState) {
  231. if (task.name.equalsIgnoreCase("bundleDebug")
  232. || task.name.equalsIgnoreCase("bundleRelease")) {
  233. copy {
  234. from 'build/intermediates/intermediary_bundle/'
  235. into 'build/outputs/bundle/'
  236. duplicatesStrategy DuplicatesStrategy.FAIL
  237. }
  238. println("afterExecute " + task.name)
  239. def aabDir = project.getBuildDir().absolutePath + '/outputs/bundle'
  240. fileTree(dir: aabDir, include: '*/*.aab').each { File file ->
  241. println(file.absolutePath)
  242. def cmd = []
  243. cmd << "java"
  244. cmd << "-jar"
  245. cmd << "${project.rootDir}/tool/bundletool.jar"
  246. cmd << "build-apks"
  247. cmd << "--bundle=" + file.absolutePath
  248. cmd << "--output=" + file.parent + File.separator + file.name.replace(".aab", "-split.apks")
  249. cmd << "--overwrite"
  250. cmd << "--mode=universal"
  251. if (task.name.equalsIgnoreCase("bundleDebug")) {
  252. cmd << "--ks=" + android.signingConfigs.debug.storeFile
  253. cmd << "--ks-pass=pass:" + android.signingConfigs.debug.storePassword
  254. cmd << "--ks-key-alias=" + android.signingConfigs.debug.keyAlias
  255. cmd << "--key-pass=pass:" + android.signingConfigs.debug.keyPassword
  256. } else {
  257. def keystoreProperties = new Properties()
  258. keystoreProperties.load(new FileInputStream(rootProject.file('keystore.properties')))
  259. cmd << "--ks=" + keystoreProperties.storeFile
  260. cmd << "--ks-pass=pass:" + keystoreProperties.storePassword
  261. cmd << "--ks-key-alias=" + keystoreProperties.keyAlias
  262. cmd << "--key-pass=pass:" + keystoreProperties.keyPassword
  263. }
  264. exec {
  265. commandLine cmd
  266. }
  267. }
  268. println("after build apks")
  269. }
  270. }
  271. })
  272. dependencies {
  273. api fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
  274. //kotlin
  275. implementation libs.kotlin.stdlib
  276. coreLibraryDesugaring libs.desugar.jdk.libs
  277. //androidx
  278. api libs.androidx.core.ktx
  279. api libs.androidx.appcompat
  280. api libs.androidx.constraint.layout
  281. api libs.androidx.activity
  282. api libs.androidx.fragment.ktx
  283. api libs.androidx.viewpager2
  284. api libs.androidx.lifecycle.livedata.ktx
  285. api libs.androidx.lifecycle.viewmodel.ktx
  286. api libs.androidx.exifinterface
  287. implementation libs.androidx.multidex
  288. implementation libs.androidx.vectordrawable
  289. implementation libs.androidx.work.manager
  290. api libs.androidx.room.runtime
  291. api libs.androidx.room.ktx
  292. api libs.flexbox
  293. kapt libs.androidx.room.compiler
  294. implementation libs.androidx.camera.core
  295. implementation libs.androidx.camera.camera2
  296. implementation libs.androidx.camera.lifecycle
  297. implementation libs.androidx.camera.video
  298. implementation libs.androidx.camera.view
  299. api libs.androidx.webkit
  300. //android
  301. implementation libs.android.material
  302. implementation libs.android.install.referrer
  303. //google play core
  304. implementation libs.play.feature.delivery
  305. implementation libs.play.feature.delivery.ktx
  306. implementation libs.play.app.update
  307. implementation libs.play.app.update.ktx
  308. //facebook
  309. implementation libs.facebook.android.sdk
  310. //appsflyer
  311. implementation libs.appsflyer
  312. //java
  313. implementation libs.rxjava
  314. //channel
  315. implementation libs.tencent.vasdolly.helper
  316. //firebase
  317. implementation platform(libs.firebase.bom)
  318. implementation libs.firebase.analytics
  319. implementation libs.firebase.crashlytics
  320. implementation libs.firebase.crashlytics.ndk
  321. implementation libs.firebase.dynamic.link
  322. implementation libs.firebase.messaging
  323. //gson
  324. implementation libs.gson
  325. //other
  326. api libs.smart.refresh.layout.kernel
  327. api libs.smart.refresh.header.material
  328. api libs.smart.refresh.footer.classics
  329. api libs.media3.exoplayer
  330. api libs.media3.exoplayer.dash
  331. api libs.media3.ui
  332. // media3 v1.4.1 guava 单独设置, 待media3更新后移除
  333. implementation libs.guava
  334. api libs.video.processor
  335. api libs.payermax
  336. api libs.rxjava
  337. //image
  338. api libs.compressor
  339. //tencent rtc
  340. // api libs.tencent.tui.core
  341. //frame
  342. api platform(libs.frame.bom)
  343. // api libs.frame.tcturing
  344. api libs.frame.animplayer
  345. api libs.frame.drawee
  346. api libs.frame.image
  347. api libs.frame.mvvm
  348. api libs.frame.util
  349. api libs.frame.zero
  350. api libs.frame.base
  351. //api libs.frame.network
  352. api project(":frame:network")
  353. api libs.frame.retrofit
  354. api libs.frame.oss
  355. api libs.frame.download
  356. api libs.frame.sound
  357. api libs.frame.game
  358. api libs.frame.autosize
  359. api libs.frame.spi
  360. api libs.frame.data
  361. api libs.frame.aab
  362. api libs.frame.coroutine
  363. api libs.frame.storage
  364. api libs.frame.log
  365. api libs.frame.statistics
  366. // api project(":frame:statistics")
  367. api libs.frame.googleservice
  368. api libs.frame.deviceid
  369. api libs.frame.security
  370. api libs.frame.guide
  371. // api libs.frame.effect
  372. api project(":frame:effect")
  373. api libs.frame.svga
  374. api libs.frame.debug
  375. api project(":frame:room")
  376. api libs.frame.startup
  377. api libs.frame.locale
  378. api libs.frame.push
  379. api libs.frame.media
  380. api libs.frame.share
  381. api libs.frame.dot
  382. api libs.frame.crash
  383. api libs.frame.apm
  384. api libs.frame.audio
  385. api libs.frame.router.annotation
  386. api libs.frame.router.api
  387. kapt libs.frame.router.compiler
  388. implementation libs.toolargetool
  389. implementation(libs.rangeseekbar)
  390. // debugApi "com.tuzhenlei:crashhandler:1.0.1"
  391. // debugApi 'cat.ereza:customactivityoncrash:2.3.0'
  392. // debugImplementation "io.github.yvescheung:Uinspector:2.0.20"
  393. // debugImplementation "io.github.yvescheung:Uinspector-optional-viewmodel:2.0.20"
  394. // debugImplementation "io.github.yvescheung:Uinspector-optional-fresco:2.0.20"
  395. // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
  396. //test
  397. testImplementation libs.junit
  398. androidTestImplementation libs.androidx.junit
  399. androidTestImplementation libs.androidx.espresso.core
  400. if (isEnableTrace) {
  401. implementation(libs.frame.trace.api)
  402. }
  403. api libs.flexbox
  404. }
  405. dependencyGuard {
  406. configuration("releaseRuntimeClasspath")
  407. }