plugins { alias(libs.plugins.android.application) } android { namespace 'com.lotus_lab.jetchat' compileSdk 35 defaultConfig { applicationId "com.lotus_lab.jetchat" minSdk 31 targetSdk 35 versionCode 1 versionName "1.0" // 你可以按需修改这个版本名 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { // 你可以在这里为 debug 构建类型添加特定的配置,如果需要的话 // 例如:applicationIdSuffix ".debug" // 这会使 debug 版的包名变为 com.lotus_lab.jetchat.debug // debuggable true // 默认就是 true } } compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 } // --- 添加以下代码来修改输出文件名 --- applicationVariants.all { variant -> variant.outputs.all { output -> def projectBaseName = "JetChat" // 你想要的基础文件名 def buildTypeName = variant.buildType.name // "debug" 或 "release" def versionName = variant.versionName // 从 defaultConfig 获取 // def versionCode = variant.versionCode // 如果你也想在文件名中包含版本号 def newFileName // 检查输出文件是 APK 还是 AAB if (output.outputFile.name.endsWith(".apk")) { // 示例格式: JetChat-release-v1.0.apk 或 JetChat-debug-v1.0.apk newFileName = "${projectBaseName}-${buildTypeName}-v${versionName}.apk" } else if (output.outputFile.name.endsWith(".aab")) { // 示例格式: JetChat-release-v1.0.aab 或 JetChat-debug-v1.0.aab newFileName = "${projectBaseName}-${buildTypeName}-v${versionName}.aab" } else { // 如果不是 APK 或 AAB (例如 mapping 文件等),保持原名 newFileName = output.outputFile.name } output.outputFileName = newFileName } } // --- 文件名修改代码结束 --- } dependencies { implementation libs.appcompat implementation libs.material testImplementation libs.junit androidTestImplementation libs.ext.junit androidTestImplementation libs.espresso.core // Retrofit & Gson Converter (用于网络请求和 JSON 解析) implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' // 可选,用于查看网络请求日志 // Room Persistence Library (用于本地数据库) def room_version = "2.6.1" // 使用最新的稳定版本 implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version" // AndroidX Core & UI Components 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.recyclerview:recyclerview:1.3.2' // Lifecycle components (可选,但推荐用于管理 Room 数据库实例) implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0" implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.7.0" }