153 lines
5.0 KiB
Plaintext
153 lines
5.0 KiB
Plaintext
import java.util.Properties
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.application)
|
|
alias(libs.plugins.kotlin.android)
|
|
alias(libs.plugins.compose.compiler)
|
|
alias(libs.plugins.kotlin.serialization)
|
|
}
|
|
|
|
val keystoreProperties = Properties().apply {
|
|
val f = rootProject.file("keystore.properties")
|
|
if (f.exists()) f.inputStream().use { load(it) }
|
|
}
|
|
|
|
android {
|
|
namespace = "com.example.tpms"
|
|
compileSdk = 36
|
|
defaultConfig {
|
|
applicationId = "com.vhelectronics.tpms"
|
|
minSdk = 21
|
|
targetSdk = 36
|
|
versionCode = 16
|
|
versionName = "1.16"
|
|
}
|
|
|
|
flavorDimensions += "distribution"
|
|
productFlavors {
|
|
create("standalone") {
|
|
dimension = "distribution"
|
|
applicationId = "com.vhelectronics.tpms"
|
|
buildConfigField("String", "UPDATE_SOURCE", "\"GITEA\"")
|
|
buildConfigField(
|
|
"String", "UPDATE_API_URL",
|
|
"\"https://git.vhelectronics.com/api/v1/repos/vhadmin/Deelife-TPMS/releases/latest\""
|
|
)
|
|
}
|
|
create("play") {
|
|
dimension = "distribution"
|
|
applicationId = "com.vhelectronics.tpms"
|
|
buildConfigField("String", "UPDATE_SOURCE", "\"PLAY\"")
|
|
buildConfigField("String", "UPDATE_API_URL", "\"\"")
|
|
}
|
|
}
|
|
|
|
signingConfigs {
|
|
// Force V1+V2+V3 signing so Android 10 file-manager sideloading works.
|
|
// AGP 9.x dropped V1 (JAR) signing by default, but older Android versions
|
|
// require V1 when installing APKs manually from a file manager.
|
|
named("debug") {
|
|
enableV1Signing = true
|
|
enableV2Signing = true
|
|
enableV3Signing = true
|
|
}
|
|
// Release key lives outside the repo. keystore.properties (git-ignored) must define
|
|
// storeFile, storePassword, keyAlias and keyPassword. Without it, assembleRelease
|
|
// produces an unsigned APK instead of silently falling back to the debug key —
|
|
// updates only install when every release is signed with the same key.
|
|
if (keystoreProperties.getProperty("storeFile") != null) {
|
|
create("release") {
|
|
storeFile = file(keystoreProperties.getProperty("storeFile"))
|
|
storePassword = keystoreProperties.getProperty("storePassword")
|
|
keyAlias = keystoreProperties.getProperty("keyAlias")
|
|
keyPassword = keystoreProperties.getProperty("keyPassword")
|
|
enableV1Signing = true
|
|
enableV2Signing = true
|
|
enableV3Signing = true
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
signingConfig = signingConfigs.getByName("debug")
|
|
}
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
|
signingConfig = signingConfigs.findByName("release")
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
buildFeatures {
|
|
compose = true
|
|
aidl = false
|
|
buildConfig = true
|
|
shaders = false
|
|
}
|
|
|
|
testOptions {
|
|
// android.util.Log etc. are stubs in local unit tests; return defaults instead of throwing.
|
|
unitTests.isReturnDefaultValues = true
|
|
}
|
|
|
|
packaging {
|
|
resources {
|
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
}
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(17)
|
|
}
|
|
|
|
dependencies {
|
|
val composeBom = platform(libs.androidx.compose.bom)
|
|
implementation(composeBom)
|
|
androidTestImplementation(composeBom)
|
|
|
|
// Core Android dependencies
|
|
implementation(libs.androidx.core.ktx)
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
implementation(libs.androidx.activity.compose)
|
|
|
|
// Arch Components
|
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
|
|
|
// Compose
|
|
implementation(libs.androidx.compose.ui)
|
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
|
implementation(libs.androidx.compose.material3)
|
|
// Tooling
|
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
|
// Instrumented tests
|
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
|
|
|
// Local tests: jUnit, coroutines, Android runner
|
|
testImplementation(libs.junit)
|
|
testImplementation(libs.kotlinx.coroutines.test)
|
|
// Real org.json for local tests (android.jar only ships stubs)
|
|
testImplementation("org.json:json:20240303")
|
|
|
|
// Instrumented tests: jUnit rules and runners
|
|
androidTestImplementation(libs.androidx.test.core)
|
|
androidTestImplementation(libs.androidx.test.ext.junit)
|
|
androidTestImplementation(libs.androidx.test.runner)
|
|
androidTestImplementation(libs.androidx.test.espresso.core)
|
|
|
|
|
|
|
|
// USB Serial
|
|
implementation("com.github.mik3y:usb-serial-for-android:3.7.3")
|
|
|
|
// Google Play (In-App Updates)
|
|
"playImplementation"(libs.play.app.update)
|
|
"playImplementation"(libs.play.app.update.ktx)
|
|
}
|