plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.compose) id("kotlin-kapt") } android { namespace 'com.narutohuo.xindazhou' compileSdk { version = release(36) } defaultConfig { applicationId "com.narutohuo.xindazhou" minSdk 26 targetSdk 36 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" // 注意:所有配置都在各自的模块的 strings.xml 中管理 // app 模块:只管理 app 模块自己的配置 // capability-push 模块:极光推送和厂商通道配置都在 capability-push/src/main/res/values/strings.xml // capability-share 模块:分享配置在 capability-share/src/main/res/values/strings.xml // 所有配置都在各自模块的 AndroidManifest.xml 中使用 @string/ 引用,完全不需要 manifestPlaceholders } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = '17' } buildFeatures { compose true viewBinding true buildConfig true // 启用 BuildConfig 生成 } // ARouter 配置(Kotlin 方式) kapt { arguments { arg("AROUTER_MODULE_NAME", project.getName()) } } // 解决资源合并冲突 packaging { resources { excludes += ['META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version'] excludes += ['META-INF/DEPENDENCIES'] excludes += ['META-INF/LICENSE'] excludes += ['META-INF/LICENSE.txt'] excludes += ['META-INF/license.txt'] excludes += ['META-INF/NOTICE'] excludes += ['META-INF/NOTICE.txt'] excludes += ['META-INF/notice.txt'] excludes += ['META-INF/ASL2.0'] } } } // 全局排除旧的 support 库,避免与 AndroidX 冲突 configurations.all { exclude group: 'com.android.support' } dependencies { // 基础模块 // 注意:app 模块不直接依赖 base-core,通过 base-common 间接获得 implementation project(':base-common') // ============================================================================ // ⚠️⚠️⚠️ 严禁直接依赖能力层里面的具体库 ⚠️⚠️⚠️ // ============================================================================ // // ❌ 禁止在 app 模块中直接依赖能力层使用的第三方 SDK,例如: // ❌ implementation 'com.tencent.mm.opensdk:wechat-sdk-android:6.8.24' // 微信 SDK // ❌ implementation 'cn.jiguang.sdk:jpush:5.9.0' // 极光推送 SDK // ❌ implementation 'com.umeng.umsdk:share-core:7.3.2' // 友盟分享 SDK // ❌ implementation files('libs/xxx.jar') // 能力层的 JAR/AAR 文件 // // ✅ 正确做法:只依赖能力模块本身,能力模块会通过 api 传递必要的依赖 // ✅ implementation project(':capability-share') // 只依赖模块 // ✅ implementation project(':capability-push') // 只依赖模块 // // 📋 原因: // 1. 每个能力模块管理自己的依赖,app 模块只负责组装 // 2. 能力模块通过 api 传递必要的依赖,app 模块会自动获得 // 3. 直接依赖会导致版本冲突、重复依赖等问题 // 4. 违反模块化原则,增加维护成本 // // ============================================================================ // SDK模块(能力层)- 只依赖模块本身,不要依赖模块内部的库! implementation project(':capability-ble') implementation project(':capability-socketio') implementation project(':capability-push') implementation project(':capability-qrcode') implementation project(':capability-share') implementation project(':capability-nfc') // 业务模块代码已迁移到 app 模块内,不再需要独立的 module-* 依赖 // AndroidX Core implementation libs.androidx.core.ktx implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.11.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.cardview:cardview:1.0.0' // ViewModel & LiveData & StateFlow implementation libs.androidx.lifecycle.runtime.ktx implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.7.0' implementation 'androidx.lifecycle:lifecycle-process:2.7.0' // ProcessLifecycleOwner(监听 App 前后台切换) // Navigation implementation 'androidx.navigation:navigation-fragment-ktx:2.7.6' implementation 'androidx.navigation:navigation-ui-ktx:2.7.6' // 注意:基础第三方库(Timber、Retrofit、OkHttp、Gson、Glide、Coroutines) // 已通过 base-common 间接获得(base-common → base-core),不需要直接依赖 // Room implementation 'androidx.room:room-runtime:2.6.1' implementation 'androidx.room:room-ktx:2.6.1' annotationProcessor 'androidx.room:room-compiler:2.6.1' // Compose implementation libs.androidx.activity.compose implementation platform(libs.androidx.compose.bom) implementation libs.androidx.compose.ui implementation libs.androidx.compose.ui.graphics implementation libs.androidx.compose.ui.tooling.preview implementation libs.androidx.compose.material3 // 调试工具(只在Debug版本使用) debugImplementation 'com.willowtreeapps.hyperion:hyperion-core:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-attr:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-measurement:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-disk:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-recorder:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-phoenix:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-crash:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-shared-preferences:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-geiger-counter:0.9.34' debugImplementation 'com.willowtreeapps.hyperion:hyperion-timber:0.9.34' // 日志查看 // Chuck - 网络请求调试(只在Debug版本使用) debugImplementation 'com.github.chuckerteam.chucker:library:4.0.0' releaseImplementation 'com.github.chuckerteam.chucker:library-no-op:4.0.0' // ARouter 编译器(用于生成路由代码) kapt 'com.alibaba:arouter-compiler:1.5.2' // Testing testImplementation libs.junit androidTestImplementation libs.androidx.junit androidTestImplementation libs.androidx.espresso.core androidTestImplementation platform(libs.androidx.compose.bom) androidTestImplementation libs.androidx.compose.ui.test.junit4 debugImplementation libs.androidx.compose.ui.tooling debugImplementation libs.androidx.compose.ui.test.manifest }