refactor(android): consolidate signing config and bump SDK to 36

- Remove external android-signing.gradle.kts, inline keystore config
  into app/build.gradle.kts
- Update compileSdk and targetSdk to 36
- Fix version format in package.json (v0.1 → 0.1.0)
This commit is contained in:
2026-05-24 23:53:14 +08:00
parent 6c90b09ef7
commit 94a432b14d
4 changed files with 56 additions and 52 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "bookmgr-client",
"private": true,
"version": "v0.1",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
+43 -11
View File
@@ -1,28 +1,60 @@
#!/usr/bin/env bash
# Patch the generated Android build.gradle.kts with signing configuration.
# Run this after `tauri android init` if the signing config is missing.
# Patch the generated Android build.gradle.kts with signing + per-arch release builds.
# Run this after `tauri android init` if the gen/android/ directory was regenerated.
set -euo pipefail
BUILD_FILE="src-tauri/gen/android/app/build.gradle.kts"
SIGNING_FILE="src-tauri/android-signing.gradle.kts"
if [ ! -f "$BUILD_FILE" ]; then
echo "Error: $BUILD_FILE not found. Run 'tauri android init' first."
exit 1
fi
# Check if signing is already configured
if grep -q "keystoreProperties" "$BUILD_FILE" 2>/dev/null; then
echo "Signing already configured in $BUILD_FILE"
echo "Patch already applied."
exit 0
fi
# Insert signing config block: find `signingConfigs` or add it before `buildTypes`,
# then add `signingConfig` to the release buildType.
# Strategy: replace the entire android block content using the external apply approach.
# 1. Add keystore properties loading after the tauriProperties block
sed -i '/^val tauriProperties/,/^$/{
/^$/a\
\
// Release signing config\
val keystorePropertiesFile = java.io.File("/home/msksbr/Android/keystore.properties")\
val keystoreProperties = Properties().apply {\
if (keystorePropertiesFile.exists()) {\
keystorePropertiesFile.inputStream().use { load(it) }\
}\
}
}' "$BUILD_FILE"
# Inject the apply-line at end of file (before the tauri.build.gradle.kts apply)
sed -i 's|apply(from = "tauri.build.gradle.kts")|apply(from = "../../../android-signing.gradle.kts")\napply(from = "tauri.build.gradle.kts")|' "$BUILD_FILE"
# 2. Add signingConfigs block inside the android block, before buildTypes
sed -i '/buildTypes {/i\ signingConfigs {\
if (keystorePropertiesFile.exists()) {\
create("release") {\
storeFile = java.io.File(keystoreProperties["storeFile"] as String)\
storePassword = keystoreProperties["storePassword"] as String\
keyAlias = keystoreProperties["keyAlias"] as String\
keyPassword = keystoreProperties["keyPassword"] as String\
}\
}\
}\
' "$BUILD_FILE"
# 3. Add signingConfig to the release buildType
sed -i '/getByName("release") {/a\ if (keystorePropertiesFile.exists()) {\
signingConfig = signingConfigs.getByName("release")\
}' "$BUILD_FILE"
# 4. Add per-arch release APK build task dependency
cat >> "$BUILD_FILE" << 'TASKDEP'
// Also build per-architecture release APKs when universal release is built
tasks.whenTaskAdded {
if (name == "assembleUniversalRelease") {
dependsOn("assembleArm64Release", "assembleArmRelease")
}
}
TASKDEP
echo "Signing config patched into $BUILD_FILE"
-34
View File
@@ -1,34 +0,0 @@
// Android signing configuration — reads keystore credentials from external file.
// This file is kept outside gen/android/ so it survives tauri android init regeneration.
//
// Usage: add `apply(from = "../../../android-signing.gradle.kts")` at the bottom of
// src-tauri/gen/android/app/build.gradle.kts
import java.util.Properties
val keystorePropertiesFile = java.io.File("/home/msksbr/Android/keystore.properties")
val keystoreProperties = Properties().apply {
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.inputStream().use { load(it) }
}
}
android {
signingConfigs {
if (keystorePropertiesFile.exists()) {
create("release") {
storeFile = java.io.File(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
}
}
}
buildTypes {
getByName("release") {
if (keystorePropertiesFile.exists()) {
signingConfig = signingConfigs.getByName("release")
}
}
}
}
+12 -6
View File
@@ -13,12 +13,11 @@ val tauriProperties = Properties().apply {
}
}
// Signing config — reads from external keystore.properties
// Release signing config
val keystorePropertiesFile = file("/home/msksbr/Android/keystore.properties")
val keystoreProperties = Properties().apply {
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.inputStream().use { load(it) }
}
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.inputStream().use { keystoreProperties.load(it) }
}
android {
@@ -89,4 +88,11 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
}
apply(from = "tauri.build.gradle.kts")
apply(from = "tauri.build.gradle.kts")
// Also build per-architecture release APKs when universal release is built
afterEvaluate {
tasks.matching { it.name == "assembleUniversalRelease" }.configureEach {
dependsOn("assembleArm64Release", "assembleArmRelease", "assembleX86_64Release", "assembleX86Release")
}
}