build(android): configure release signing with keystore

Replaces default debug signing with a dedicated release keystore loaded via android/key.properties. Fixes the cross-host signature mismatch that broke adb install -r. keystore and key.properties are gitignored (signing identity must not be committed).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-08-10 13:43:29 +08:00
parent 99ed3bb9ec
commit a702f80116
2 changed files with 23 additions and 3 deletions

4
.gitignore vendored
View File

@@ -46,6 +46,10 @@ app.*.map.json
/android/app/release
/android/build/
# Release signing keystore (do NOT commit — contains signing identity)
/android/key.properties
/android/app/key.jks
# AI Agents
.claude/
.agents/

View File

@@ -1,3 +1,6 @@
import java.util.Properties
import java.io.FileInputStream
plugins {
id("com.android.application")
id("kotlin-android")
@@ -5,11 +8,26 @@ plugins {
id("dev.flutter.flutter-gradle-plugin")
}
val keystoreProperties = Properties()
val keystorePropertiesFile = rootProject.file("key.properties")
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android {
namespace = "com.example.pad_scanner"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
signingConfigs {
create("release") {
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
@@ -32,9 +50,7 @@ android {
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig = signingConfigs.getByName("debug")
signingConfig = signingConfigs.getByName("release")
}
}
}