android: load release signing from keystore.properties
Read upload-keystore credentials from a gitignored keystore.properties (falling back to unsigned release when absent), bundle full native debug symbols for Play crash symbolication, and ignore keystore secrets. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
5
android/.gitignore
vendored
5
android/.gitignore
vendored
@@ -11,3 +11,8 @@
|
|||||||
|
|
||||||
# Local build artifacts
|
# Local build artifacts
|
||||||
*.apk
|
*.apk
|
||||||
|
|
||||||
|
# Signing — never commit the keystore or its passwords
|
||||||
|
keystore.properties
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import java.io.FileInputStream
|
||||||
|
import java.util.Properties
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
alias(libs.plugins.kotlin.android)
|
alias(libs.plugins.kotlin.android)
|
||||||
@@ -6,6 +9,14 @@ plugins {
|
|||||||
alias(libs.plugins.ksp)
|
alias(libs.plugins.ksp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Release signing credentials, loaded from android/keystore.properties (gitignored).
|
||||||
|
// Falls back to no release signing when the file/keystore is absent (e.g. CI without secrets).
|
||||||
|
val keystoreProps = Properties().apply {
|
||||||
|
val f = rootProject.file("keystore.properties")
|
||||||
|
if (f.exists()) load(FileInputStream(f))
|
||||||
|
}
|
||||||
|
val hasReleaseSigning = keystoreProps.getProperty("storeFile")?.let { file(it).exists() } == true
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "app.voltplan.cable"
|
namespace = "app.voltplan.cable"
|
||||||
compileSdk = 35
|
compileSdk = 35
|
||||||
@@ -25,17 +36,35 @@ android {
|
|||||||
resourceConfigurations += listOf("en", "de", "es", "fr", "nl")
|
resourceConfigurations += listOf("en", "de", "es", "fr", "nl")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
if (hasReleaseSigning) {
|
||||||
|
create("release") {
|
||||||
|
storeFile = file(keystoreProps.getProperty("storeFile"))
|
||||||
|
storePassword = keystoreProps.getProperty("storePassword")
|
||||||
|
keyAlias = keystoreProps.getProperty("keyAlias")
|
||||||
|
keyPassword = keystoreProps.getProperty("keyPassword")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
isMinifyEnabled = false
|
isMinifyEnabled = false
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
|
if (hasReleaseSigning) {
|
||||||
|
signingConfig = signingConfigs.getByName("release")
|
||||||
|
}
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
isShrinkResources = true
|
isShrinkResources = true
|
||||||
proguardFiles(
|
proguardFiles(
|
||||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
"proguard-rules.pro",
|
"proguard-rules.pro",
|
||||||
)
|
)
|
||||||
|
// Bundle native debug symbols so Play can symbolicate native crashes/ANRs.
|
||||||
|
ndk {
|
||||||
|
debugSymbolLevel = "FULL"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user