build.gradle 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. plugins {
  2. alias(libs.plugins.android.application)
  3. alias(libs.plugins.kotlin.android)
  4. alias(libs.plugins.kotlin.compose)
  5. }
  6. android {
  7. namespace 'com.narutohuo.xindazhou'
  8. compileSdk {
  9. version = release(36)
  10. }
  11. // 从资源文件读取配置值(用于 manifestPlaceholders)
  12. // 这样所有配置都在 strings.xml 中,build.gradle 只是读取并设置占位符
  13. def getStringResource = { String name ->
  14. def resFile = file("src/main/res/values/strings.xml")
  15. if (!resFile.exists()) {
  16. return ""
  17. }
  18. def xml = new XmlParser().parse(resFile)
  19. def stringNode = xml.string.find { it.@name == name }
  20. return stringNode ? stringNode.text() : ""
  21. }
  22. defaultConfig {
  23. applicationId "com.narutohuo.xindazhou"
  24. minSdk 26
  25. targetSdk 36
  26. versionCode 1
  27. versionName "1.0"
  28. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  29. // SDK 占位符配置(从资源文件读取,所有值都在 strings.xml 中)
  30. // 这样用户只需要在 strings.xml 中配置一次,不需要在 AndroidManifest.xml 中手动填写
  31. // QQ scheme 处理:优先使用 qq_app_id_scheme,如果没有则使用 qq_app_id 拼接
  32. def qqAppIdScheme = getStringResource("qq_app_id_scheme")
  33. def qqAppId = getStringResource("qq_app_id")
  34. def qqScheme = ""
  35. if (qqAppIdScheme && !qqAppIdScheme.contains("your_qq_appid_here")) {
  36. qqScheme = qqAppIdScheme
  37. } else if (qqAppId && !qqAppId.contains("your_qq_appid_here")) {
  38. qqScheme = "tencent" + qqAppId
  39. } else {
  40. qqScheme = "tencentyour_qq_appid_here"
  41. }
  42. manifestPlaceholders = [
  43. JPUSH_APPKEY: getStringResource("jpush_app_key") ?: "your_jpush_appkey_here",
  44. JPUSH_CHANNEL: getStringResource("push_jpush_channel") ?: "developer-default",
  45. // QQ scheme 格式:tencent + qq_app_id(例如:tencent1101234567)
  46. qqappid: qqScheme
  47. ]
  48. }
  49. buildTypes {
  50. release {
  51. minifyEnabled false
  52. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  53. }
  54. }
  55. compileOptions {
  56. sourceCompatibility JavaVersion.VERSION_17
  57. targetCompatibility JavaVersion.VERSION_17
  58. }
  59. kotlinOptions {
  60. jvmTarget = '17'
  61. }
  62. buildFeatures {
  63. compose true
  64. viewBinding true
  65. buildConfig true // 启用 BuildConfig 生成
  66. }
  67. }
  68. dependencies {
  69. // 基础模块
  70. implementation project(':base-core')
  71. implementation project(':base-common')
  72. // SDK模块(能力层)
  73. implementation project(':capability-ble')
  74. implementation project(':capability-socketio')
  75. implementation project(':capability-push')
  76. implementation project(':capability-qrcode')
  77. implementation project(':capability-share')
  78. implementation project(':capability-nfc')
  79. // 友盟分享需要的第三方平台 SDK(确保运行时能找到)
  80. // 注意:友盟分享模块已经添加了这些依赖,但为了确保运行时能找到,也在 app 模块中添加
  81. implementation("com.tencent.mm.opensdk:wechat-sdk-android:6.8.24")
  82. // 业务模块代码已迁移到 app 模块内,不再需要独立的 module-* 依赖
  83. // AndroidX Core
  84. implementation libs.androidx.core.ktx
  85. implementation 'androidx.appcompat:appcompat:1.6.1'
  86. implementation 'com.google.android.material:material:1.11.0'
  87. implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
  88. implementation 'androidx.cardview:cardview:1.0.0'
  89. // ViewModel & LiveData & StateFlow
  90. implementation libs.androidx.lifecycle.runtime.ktx
  91. implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0'
  92. implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0'
  93. // Kotlin Coroutines
  94. implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
  95. implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
  96. // Navigation
  97. implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6'
  98. implementation 'androidx.navigation:navigation-ui-ktx:2.7.6'
  99. // Timber (日志库,用于Hyperion)
  100. implementation 'com.jakewharton.timber:timber:5.0.1'
  101. // Retrofit & OkHttp
  102. implementation 'com.squareup.retrofit2:retrofit:2.9.0'
  103. implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
  104. implementation 'com.squareup.okhttp3:okhttp:4.12.0'
  105. implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
  106. // Glide
  107. implementation 'com.github.bumptech.glide:glide:4.16.0'
  108. // Room
  109. implementation 'androidx.room:room-runtime:2.6.1'
  110. implementation 'androidx.room:room-ktx:2.6.1'
  111. annotationProcessor 'androidx.room:room-compiler:2.6.1'
  112. // Compose
  113. implementation libs.androidx.activity.compose
  114. implementation platform(libs.androidx.compose.bom)
  115. implementation libs.androidx.compose.ui
  116. implementation libs.androidx.compose.ui.graphics
  117. implementation libs.androidx.compose.ui.tooling.preview
  118. implementation libs.androidx.compose.material3
  119. // 调试工具(只在Debug版本使用)
  120. debugImplementation 'com.willowtreeapps.hyperion:hyperion-core:0.9.34'
  121. debugImplementation 'com.willowtreeapps.hyperion:hyperion-attr:0.9.34'
  122. debugImplementation 'com.willowtreeapps.hyperion:hyperion-measurement:0.9.34'
  123. debugImplementation 'com.willowtreeapps.hyperion:hyperion-disk:0.9.34'
  124. debugImplementation 'com.willowtreeapps.hyperion:hyperion-recorder:0.9.34'
  125. debugImplementation 'com.willowtreeapps.hyperion:hyperion-phoenix:0.9.34'
  126. debugImplementation 'com.willowtreeapps.hyperion:hyperion-crash:0.9.34'
  127. debugImplementation 'com.willowtreeapps.hyperion:hyperion-shared-preferences:0.9.34'
  128. debugImplementation 'com.willowtreeapps.hyperion:hyperion-geiger-counter:0.9.34'
  129. debugImplementation 'com.willowtreeapps.hyperion:hyperion-timber:0.9.34' // 日志查看
  130. // Chuck - 网络请求调试(只在Debug版本使用)
  131. debugImplementation 'com.github.chuckerteam.chucker:library:4.0.0'
  132. releaseImplementation 'com.github.chuckerteam.chucker:library-no-op:4.0.0'
  133. // Testing
  134. testImplementation libs.junit
  135. androidTestImplementation libs.androidx.junit
  136. androidTestImplementation libs.androidx.espresso.core
  137. androidTestImplementation platform(libs.androidx.compose.bom)
  138. androidTestImplementation libs.androidx.compose.ui.test.junit4
  139. debugImplementation libs.androidx.compose.ui.tooling
  140. debugImplementation libs.androidx.compose.ui.test.manifest
  141. }