build.gradle 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. plugins {
  2. alias(libs.plugins.android.application)
  3. alias(libs.plugins.kotlin.android)
  4. alias(libs.plugins.kotlin.compose)
  5. id("kotlin-kapt")
  6. }
  7. android {
  8. namespace 'com.narutohuo.xindazhou'
  9. compileSdk {
  10. version = release(36)
  11. }
  12. defaultConfig {
  13. applicationId "com.narutohuo.xindazhou"
  14. minSdk 26
  15. targetSdk 36
  16. versionCode 1
  17. versionName "1.0"
  18. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  19. // 注意:所有配置都在各自的模块的 strings.xml 中管理
  20. // app 模块:只管理 app 模块自己的配置
  21. // capability-push 模块:极光推送和厂商通道配置都在 capability-push/src/main/res/values/strings.xml
  22. // capability-share 模块:分享配置在 capability-share/src/main/res/values/strings.xml
  23. // 所有配置都在各自模块的 AndroidManifest.xml 中使用 @string/ 引用,完全不需要 manifestPlaceholders
  24. }
  25. buildTypes {
  26. release {
  27. minifyEnabled false
  28. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  29. }
  30. }
  31. compileOptions {
  32. sourceCompatibility JavaVersion.VERSION_17
  33. targetCompatibility JavaVersion.VERSION_17
  34. }
  35. kotlinOptions {
  36. jvmTarget = '17'
  37. }
  38. buildFeatures {
  39. compose true
  40. viewBinding true
  41. buildConfig true // 启用 BuildConfig 生成
  42. }
  43. // ARouter 配置(Kotlin 方式)
  44. kapt {
  45. arguments {
  46. arg("AROUTER_MODULE_NAME", project.getName())
  47. }
  48. }
  49. // 解决资源合并冲突
  50. packaging {
  51. resources {
  52. excludes += ['META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version']
  53. excludes += ['META-INF/DEPENDENCIES']
  54. excludes += ['META-INF/LICENSE']
  55. excludes += ['META-INF/LICENSE.txt']
  56. excludes += ['META-INF/license.txt']
  57. excludes += ['META-INF/NOTICE']
  58. excludes += ['META-INF/NOTICE.txt']
  59. excludes += ['META-INF/notice.txt']
  60. excludes += ['META-INF/ASL2.0']
  61. }
  62. }
  63. }
  64. // 全局排除旧的 support 库,避免与 AndroidX 冲突
  65. configurations.all {
  66. exclude group: 'com.android.support'
  67. }
  68. dependencies {
  69. // 基础模块
  70. // 注意:app 模块不直接依赖 base-core,通过 base-common 间接获得
  71. implementation project(':base-common')
  72. // ============================================================================
  73. // ⚠️⚠️⚠️ 严禁直接依赖能力层里面的具体库 ⚠️⚠️⚠️
  74. // ============================================================================
  75. //
  76. // ❌ 禁止在 app 模块中直接依赖能力层使用的第三方 SDK,例如:
  77. // ❌ implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.24' // 微信 SDK
  78. // ❌ implementation 'cn.jiguang.sdk:jpush:5.9.0' // 极光推送 SDK
  79. // ❌ implementation 'com.umeng.umsdk:share-core:7.3.2' // 友盟分享 SDK
  80. // ❌ implementation files('libs/xxx.jar') // 能力层的 JAR/AAR 文件
  81. //
  82. // ✅ 正确做法:只依赖能力模块本身,能力模块会通过 api 传递必要的依赖
  83. // ✅ implementation project(':capability-share') // 只依赖模块
  84. // ✅ implementation project(':capability-push') // 只依赖模块
  85. //
  86. // 📋 原因:
  87. // 1. 每个能力模块管理自己的依赖,app 模块只负责组装
  88. // 2. 能力模块通过 api 传递必要的依赖,app 模块会自动获得
  89. // 3. 直接依赖会导致版本冲突、重复依赖等问题
  90. // 4. 违反模块化原则,增加维护成本
  91. //
  92. // ============================================================================
  93. // SDK模块(能力层)- 只依赖模块本身,不要依赖模块内部的库!
  94. implementation project(':capability-ble')
  95. // Socket.IO 已迁移到 base-common,不再需要 capability-socketio 模块
  96. // implementation project(':capability-socketio')
  97. implementation project(':capability-push')
  98. implementation project(':capability-qrcode')
  99. implementation project(':capability-share')
  100. implementation project(':capability-nfc')
  101. // 业务模块代码已迁移到 app 模块内,不再需要独立的 module-* 依赖
  102. // AndroidX Core
  103. implementation libs.androidx.core.ktx
  104. implementation 'androidx.appcompat:appcompat:1.6.1'
  105. implementation 'com.google.android.material:material:1.11.0'
  106. implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
  107. implementation 'androidx.cardview:cardview:1.0.0'
  108. // ViewModel & LiveData & StateFlow
  109. implementation libs.androidx.lifecycle.runtime.ktx
  110. implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
  111. implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0'
  112. implementation 'androidx.lifecycle:lifecycle-process:2.7.0' // ProcessLifecycleOwner(监听 App 前后台切换)
  113. // Navigation
  114. implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6'
  115. implementation 'androidx.navigation:navigation-ui-ktx:2.7.6'
  116. // 注意:基础第三方库(Timber、Retrofit、OkHttp、Gson、Glide、Coroutines)
  117. // 已通过 base-common 间接获得(base-common → base-core),不需要直接依赖
  118. // Room
  119. implementation 'androidx.room:room-runtime:2.6.1'
  120. implementation 'androidx.room:room-ktx:2.6.1'
  121. annotationProcessor 'androidx.room:room-compiler:2.6.1'
  122. // Compose
  123. implementation libs.androidx.activity.compose
  124. implementation platform(libs.androidx.compose.bom)
  125. implementation libs.androidx.compose.ui
  126. implementation libs.androidx.compose.ui.graphics
  127. implementation libs.androidx.compose.ui.tooling.preview
  128. implementation libs.androidx.compose.material3
  129. // 调试工具(只在Debug版本使用)
  130. debugImplementation 'com.willowtreeapps.hyperion:hyperion-core:0.9.34'
  131. debugImplementation 'com.willowtreeapps.hyperion:hyperion-attr:0.9.34'
  132. debugImplementation 'com.willowtreeapps.hyperion:hyperion-measurement:0.9.34'
  133. debugImplementation 'com.willowtreeapps.hyperion:hyperion-disk:0.9.34'
  134. debugImplementation 'com.willowtreeapps.hyperion:hyperion-recorder:0.9.34'
  135. debugImplementation 'com.willowtreeapps.hyperion:hyperion-phoenix:0.9.34'
  136. debugImplementation 'com.willowtreeapps.hyperion:hyperion-crash:0.9.34'
  137. debugImplementation 'com.willowtreeapps.hyperion:hyperion-shared-preferences:0.9.34'
  138. debugImplementation 'com.willowtreeapps.hyperion:hyperion-geiger-counter:0.9.34'
  139. debugImplementation 'com.willowtreeapps.hyperion:hyperion-timber:0.9.34' // 日志查看
  140. // Chuck - 网络请求调试(只在Debug版本使用)
  141. debugImplementation 'com.github.chuckerteam.chucker:library:4.0.0'
  142. releaseImplementation 'com.github.chuckerteam.chucker:library-no-op:4.0.0'
  143. // ARouter 编译器(用于生成路由代码)
  144. kapt 'com.alibaba:arouter-compiler:1.5.2'
  145. // Testing
  146. testImplementation libs.junit
  147. androidTestImplementation libs.androidx.junit
  148. androidTestImplementation libs.androidx.espresso.core
  149. androidTestImplementation platform(libs.androidx.compose.bom)
  150. androidTestImplementation libs.androidx.compose.ui.test.junit4
  151. debugImplementation libs.androidx.compose.ui.tooling
  152. debugImplementation libs.androidx.compose.ui.test.manifest
  153. }