146 lines
4.3 KiB
Kotlin
146 lines
4.3 KiB
Kotlin
plugins {
|
||
alias(libs.plugins.android.application)
|
||
alias(libs.plugins.kotlin.android)
|
||
alias(libs.plugins.ksp)
|
||
alias(libs.plugins.hilt)
|
||
}
|
||
|
||
android {
|
||
namespace = "com.xiaoqu.watch"
|
||
compileSdk = 36
|
||
|
||
defaultConfig {
|
||
applicationId = "com.xiaoqu.watch"
|
||
minSdk = 27
|
||
targetSdk = 27
|
||
versionCode = 183
|
||
versionName = "2.0.0"
|
||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||
}
|
||
|
||
// 发布时用 productFlavors 切换包名:
|
||
// dev: com.xiaoqu.watch(调试用,和旧版不冲突)
|
||
// prod: com.witClean.watch(正式发布,旧版 OTA 升级)
|
||
flavorDimensions += "env"
|
||
productFlavors {
|
||
create("dev") {
|
||
dimension = "env"
|
||
applicationId = "com.xiaoqu.watch"
|
||
}
|
||
create("prod") {
|
||
dimension = "env"
|
||
applicationId = "com.witClean.watch"
|
||
}
|
||
}
|
||
|
||
buildTypes {
|
||
debug {
|
||
buildConfigField("String", "SERVICE_URL", "\"https://app.updatexiaoqu.com:9443/\"")
|
||
// MQTT TCP 连接地址(端口 1883 在 MqttConfig 中定义)
|
||
buildConfigField("String", "MQTT_HOST", "\"mqtt.ququbranch.com\"")
|
||
}
|
||
release {
|
||
isMinifyEnabled = false
|
||
proguardFiles(
|
||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||
"proguard-rules.pro"
|
||
)
|
||
buildConfigField("String", "SERVICE_URL", "\"https://app.updatexiaoqu.com:9443/\"")
|
||
buildConfigField("String", "MQTT_HOST", "\"mqtt.ququbranch.com\"")
|
||
}
|
||
}
|
||
|
||
compileOptions {
|
||
sourceCompatibility = JavaVersion.VERSION_11
|
||
targetCompatibility = JavaVersion.VERSION_11
|
||
}
|
||
|
||
kotlinOptions {
|
||
jvmTarget = "11"
|
||
}
|
||
|
||
buildFeatures {
|
||
viewBinding = true
|
||
buildConfig = true
|
||
}
|
||
|
||
// 手表设备不上 Google Play,跳过 targetSdk 版本检查
|
||
lint {
|
||
disable += "ExpiredTargetSdkVersion"
|
||
}
|
||
|
||
// APK 文件名包含版本信息,如:小趣智清洁-v2.0.0(183)-prod-release.apk
|
||
applicationVariants.all {
|
||
val variant = this
|
||
variant.outputs.all {
|
||
val output = this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
|
||
val versionName = variant.versionName
|
||
val versionCode = variant.versionCode
|
||
val flavorName = variant.flavorName
|
||
val buildType = variant.buildType.name
|
||
output.outputFileName = "小趣智清洁-v${versionName}(${versionCode})-${flavorName}-${buildType}.apk"
|
||
}
|
||
}
|
||
}
|
||
|
||
dependencies {
|
||
// Core
|
||
implementation(libs.androidx.core.ktx)
|
||
implementation(libs.androidx.appcompat)
|
||
implementation(libs.material)
|
||
implementation(libs.androidx.activity)
|
||
implementation(libs.androidx.fragment)
|
||
implementation(libs.androidx.constraintlayout)
|
||
implementation(libs.androidx.viewpager2)
|
||
implementation(libs.androidx.swiperefreshlayout)
|
||
|
||
// Lifecycle
|
||
implementation(libs.androidx.lifecycle.viewmodel)
|
||
implementation(libs.androidx.lifecycle.livedata)
|
||
implementation(libs.androidx.lifecycle.runtime)
|
||
|
||
// Navigation
|
||
implementation(libs.androidx.navigation.fragment)
|
||
implementation(libs.androidx.navigation.ui)
|
||
|
||
// Hilt
|
||
implementation(libs.hilt.android)
|
||
ksp(libs.hilt.compiler)
|
||
|
||
// Coroutines
|
||
implementation(libs.kotlinx.coroutines.core)
|
||
implementation(libs.kotlinx.coroutines.android)
|
||
|
||
// Room
|
||
implementation(libs.androidx.room.runtime)
|
||
implementation(libs.androidx.room.ktx)
|
||
ksp(libs.androidx.room.compiler)
|
||
|
||
// TLS (解决 Android 8.1 连阿里云 OSS HTTPS 握手失败)
|
||
implementation(libs.conscrypt)
|
||
|
||
// Network
|
||
implementation(libs.retrofit)
|
||
implementation(libs.retrofit.converter.gson)
|
||
implementation(libs.okhttp)
|
||
implementation(libs.okhttp.logging)
|
||
implementation(libs.gson)
|
||
|
||
// MQTT
|
||
implementation(libs.paho.mqtt)
|
||
|
||
// Logging
|
||
implementation(libs.timber)
|
||
|
||
// QR Code
|
||
implementation(libs.zxing.core)
|
||
|
||
// Test
|
||
testImplementation(libs.junit)
|
||
testImplementation(libs.mockk)
|
||
testImplementation(libs.kotlinx.coroutines.test)
|
||
androidTestImplementation(libs.androidx.junit)
|
||
androidTestImplementation(libs.androidx.espresso.core)
|
||
}
|