1. 遞增 app/build.gradle 中的 verPatch 變數至 8(對應版本為 10_08_8_R,versionCode 為 100808),以利機台正常觸發 OTA 覆蓋安裝。 2. 重構 .agents/workflows/compiler-apk.md 腳本中的 APK 複製與命名機制,改為動態尋找並使用原始檔名,避免寫死檔名導致版本變更時失效。 3. 在編譯腳本中加入自動提取與計算版本資訊的輸出(包含 versionName 與 versionCode),方便在 StarCloud 後台登記時作為參考。 4. 更新 ADB 自動安裝路徑尋找方式,使其與動態尋找 APK 機制保持一致。
101 lines
3.1 KiB
Groovy
101 lines
3.1 KiB
Groovy
plugins {
|
||
alias(libs.plugins.android.application)
|
||
}
|
||
|
||
// =========================================================================
|
||
// 核心版號與自動連動定義
|
||
// 每次發佈新版本給機台時,只需遞增 verPatch (修補版號)。
|
||
// 例如:從 5 改為 6,對應的 versionName 就會自動變成 "10_08_6_R",
|
||
// versionCode 就會自動變大為 100806,以正確觸發實體機台的 OTA 自動更新。
|
||
// =========================================================================
|
||
def verMajor = 10
|
||
def verMinor = 8
|
||
def verPatch = 8
|
||
|
||
android {
|
||
namespace 'com.unibuy.smartdevice'
|
||
compileSdk 35
|
||
|
||
defaultConfig {
|
||
applicationId "com.unibuy.smartdevice"
|
||
minSdk 21
|
||
targetSdk 34
|
||
versionCode verMajor * 10000 + verMinor * 100 + verPatch
|
||
versionName "${verMajor}_0${verMinor}_${verPatch}_R"
|
||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||
}
|
||
|
||
// 設定不同場域
|
||
flavorDimensions "app_type"
|
||
|
||
productFlavors {
|
||
S_12_XY_U_Standard_ {
|
||
dimension "app_type"
|
||
versionCode verMajor * 10000 + verMinor * 100 + verPatch
|
||
versionName "${verMajor}_0${verMinor}_${verPatch}_R"
|
||
}
|
||
}
|
||
|
||
buildTypes {
|
||
release {
|
||
minifyEnabled false
|
||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||
signingConfig signingConfigs.debug
|
||
}
|
||
}
|
||
|
||
// 自定義打包檔案名稱,包含版本號
|
||
applicationVariants.all { variant ->
|
||
variant.outputs.each { output ->
|
||
def versionCode = variant.versionCode
|
||
def versionName = variant.versionName
|
||
def flavor = variant.productFlavors[0].name
|
||
def buildType = variant.buildType.name
|
||
|
||
// 設定打包檔案名稱:app-<flavor>-<versionName>-<buildType>.apk
|
||
output.outputFileName = "app-${flavor}-${versionName}-${buildType}.apk"
|
||
}
|
||
}
|
||
|
||
compileOptions {
|
||
sourceCompatibility JavaVersion.VERSION_11
|
||
targetCompatibility JavaVersion.VERSION_11
|
||
}
|
||
|
||
buildFeatures {
|
||
viewBinding true
|
||
}
|
||
|
||
packaging {
|
||
resources {
|
||
excludes += ['META-INF/INDEX.LIST', 'META-INF/io.netty.versions.properties']
|
||
}
|
||
}
|
||
}
|
||
|
||
dependencies {
|
||
implementation libs.appcompat
|
||
implementation libs.material
|
||
implementation libs.activity
|
||
implementation libs.constraintlayout
|
||
implementation libs.work.runtime
|
||
testImplementation libs.junit
|
||
androidTestImplementation libs.ext.junit
|
||
androidTestImplementation libs.espresso.core
|
||
|
||
annotationProcessor libs.compiler
|
||
implementation libs.usb.serial.for.android
|
||
implementation libs.android.serialport
|
||
implementation libs.glide
|
||
implementation libs.media3.exoplayer
|
||
implementation libs.media3.ui
|
||
implementation libs.tsnackBar
|
||
|
||
implementation 'com.blankj:utilcodex:1.31.1'
|
||
implementation 'com.hivemq:hivemq-mqtt-client:1.3.3'
|
||
implementation 'io.netty:netty-codec-http:4.1.94.Final'
|
||
implementation 'io.netty:netty-handler:4.1.94.Final'
|
||
implementation 'com.google.code.gson:gson:2.10.1'
|
||
}
|