- compileSdk/targetSdk 36: Google Play rejects new apps below API 36 since 31 August 2026. - Release signing from ANDROID_KEYSTORE_* environment variables or local.properties; unsigned when no upload key is configured. - versionCode/versionName overridable via VERSION_CODE/VERSION_NAME. - scripts/build-release-aab.sh builds and verifies a signed AAB. - CI installs platform 36 until the CI image is rebuilt. - Document the internal-testing upload flow.
This commit is contained in:
1 parent
43bd9629d3
commit
9b105b3925
6 files changed
+179
-10
No files matched your search
@@ -25,6 +25,16 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# The app targets API 36, which Play requires for new uploads. The CI
|
||||
# image still ships API 35, so install 36 on demand until it is rebuilt.
|
||||
- name: Ensure Android SDK 36
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ ! -d "$ANDROID_HOME/platforms/android-36" ]; then
|
||||
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \
|
||||
"platforms;android-36" "build-tools;36.0.0" >/dev/null
|
||||
fi
|
||||
|
||||
- name: Test and build
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -7,3 +7,5 @@ local.properties
|
||||
.DS_Store
|
||||
.kotlin/
|
||||
node_modules/
|
||||
*.jks
|
||||
*.keystore
|
||||
@@ -60,15 +60,15 @@ composeApp/
|
||||
|
||||
## Build
|
||||
|
||||
Requirements: JDK 21, Android SDK 35 for the app target, Node (Kotlin downloads its own for web).
|
||||
Requirements: JDK 21, Android SDK 36 for the app target, Node (Kotlin downloads its own for web).
|
||||
|
||||
With Nix, everything is provided by `shell.nix` (JDK 21, Gradle 8, Node 22, Android SDK 35 with build-tools 35.0.0, and the desktop runtime libraries):
|
||||
With Nix, everything is provided by `shell.nix` (JDK 21, Gradle 8, Node 22, Android SDK 36 with build-tools 36.0.0, and the desktop runtime libraries):
|
||||
|
||||
```bash
|
||||
nix-shell
|
||||
```
|
||||
|
||||
The shell accepts the unfree Android SDK license for you; see the comment at the top of `shell.nix`. Without Nix, point `ANDROID_HOME` at an SDK containing platform 35 and build-tools 35.0.0.
|
||||
The shell accepts the unfree Android SDK license for you; see the comment at the top of `shell.nix`. Without Nix, point `ANDROID_HOME` at an SDK containing platform 36 and build-tools 36.0.0.
|
||||
|
||||
```bash
|
||||
export ANDROID_HOME=/opt/android-sdk
|
||||
@@ -95,11 +95,63 @@ Serve the web bundle from any static host (for example `python3 -m http.server`
|
||||
|
||||
Android cleartext HTTP is enabled for local development. Use HTTPS in production.
|
||||
|
||||
## Publishing to Google Play (internal testing)
|
||||
|
||||
The application id `win.taptap.musicmanager.client` is fixed after the first
|
||||
upload. Google Play requires new apps to target API 36, and every upload needs a
|
||||
higher `versionCode`.
|
||||
|
||||
### 1. Upload key (once)
|
||||
|
||||
Play App Signing keeps the real signing key; this project only needs an upload
|
||||
key. Create it and store the keystore plus both passwords in a password manager:
|
||||
|
||||
```bash
|
||||
keytool -genkeypair -v -keystore upload-keystore.jks -storetype PKCS12 \
|
||||
-alias upload -keyalg RSA -keysize 4096 -validity 10000
|
||||
```
|
||||
|
||||
Add the values to `local.properties` (git-ignored) or export them in CI:
|
||||
|
||||
```properties
|
||||
UPLOAD_STORE_FILE=/absolute/path/upload-keystore.jks
|
||||
UPLOAD_STORE_PASSWORD=...
|
||||
UPLOAD_KEY_ALIAS=upload
|
||||
UPLOAD_KEY_PASSWORD=...
|
||||
```
|
||||
|
||||
CI equivalents: `ANDROID_KEYSTORE_PATH`, `ANDROID_KEYSTORE_PASSWORD`,
|
||||
`ANDROID_KEY_ALIAS`, `ANDROID_KEY_PASSWORD`.
|
||||
|
||||
### 2. Build the bundle
|
||||
|
||||
```bash
|
||||
scripts/build-release-aab.sh <versionCode> <versionName>
|
||||
# composeApp/build/outputs/bundle/release/composeApp-release.aab
|
||||
```
|
||||
|
||||
The script verifies the signature and prints the SHA-256. Bump `versionCode` for
|
||||
every upload; `VERSION_CODE`/`VERSION_NAME` can also be set in the environment.
|
||||
|
||||
### 3. Upload
|
||||
|
||||
In Play Console: **Testing → Internal testing → Create new release → App
|
||||
integrity → Google-generated key**, upload the AAB, add release notes, then
|
||||
**Save → Roll out**. The first upload enrolls the app in Play App Signing. Share
|
||||
the opt-in link from the Testers tab with your test list.
|
||||
|
||||
### 4. Automated uploads (later)
|
||||
|
||||
Create a service account in Google Cloud, enable the **Google Play Android
|
||||
Developer API**, and grant the service account release permissions for this app
|
||||
in Play Console. Then wire Gradle Play Publisher with the service account JSON.
|
||||
The first AAB must still be uploaded manually.
|
||||
|
||||
## App state and offline behaviour
|
||||
|
||||
`AppStore` is a plain Kotlin class with a `StateFlow<AppState>`; Compose observes it. It owns:
|
||||
|
||||
- **Auth** — restore token, refresh token, logout.
|
||||
- **Auth** — restore the saved token on launch and log out.
|
||||
- **Library sync** — first launch pages through `/library/songs`; later launches use the `since` delta and tombstones. Songs are split into music and longform using the folders assigned at login, so the two never mix client-side.
|
||||
- **Mood cache** — mood details are stored so the app can open them offline.
|
||||
- **Radio** — one session per mood, batches of 12, prefetch when the queue is short, no repeats within a session.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@file:OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
|
||||
|
||||
import java.util.Properties
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
@@ -11,6 +12,34 @@ plugins {
|
||||
id("com.android.application")
|
||||
}
|
||||
|
||||
// Release signing and version numbers come from the environment in CI, or from
|
||||
// local.properties for local release builds. Nothing secret is committed:
|
||||
// local.properties is git-ignored. Without an upload key the release build
|
||||
// still works, but the AAB is unsigned and cannot be uploaded to Play.
|
||||
val localProperties = Properties().apply {
|
||||
val file = rootProject.file("local.properties")
|
||||
if (file.exists()) file.inputStream().use { load(it) }
|
||||
}
|
||||
|
||||
fun signingValue(property: String, env: String): String? =
|
||||
(System.getenv(env) ?: localProperties.getProperty(property))?.takeIf { it.isNotBlank() }
|
||||
|
||||
val uploadKeyStore = signingValue("UPLOAD_STORE_FILE", "ANDROID_KEYSTORE_PATH")?.let { rootProject.file(it) }
|
||||
val uploadKeyStorePassword = signingValue("UPLOAD_STORE_PASSWORD", "ANDROID_KEYSTORE_PASSWORD")
|
||||
val uploadKeyAlias = signingValue("UPLOAD_KEY_ALIAS", "ANDROID_KEY_ALIAS")
|
||||
val uploadKeyPassword = signingValue("UPLOAD_KEY_PASSWORD", "ANDROID_KEY_PASSWORD")
|
||||
val hasUploadKey = uploadKeyStore?.exists() == true &&
|
||||
!uploadKeyStorePassword.isNullOrEmpty() &&
|
||||
!uploadKeyAlias.isNullOrEmpty() &&
|
||||
!uploadKeyPassword.isNullOrEmpty()
|
||||
|
||||
// Play requires a strictly increasing versionCode for every upload. CI can pass
|
||||
// VERSION_CODE / VERSION_NAME (for example from the git tag).
|
||||
val appVersionCode = (System.getenv("VERSION_CODE") ?: localProperties.getProperty("VERSION_CODE") ?: "1").toInt()
|
||||
val appVersionName = System.getenv("VERSION_NAME")
|
||||
?: localProperties.getProperty("VERSION_NAME")
|
||||
?: "0.1.0"
|
||||
|
||||
kotlin {
|
||||
androidTarget {
|
||||
compilerOptions {
|
||||
@@ -85,14 +114,35 @@ kotlin {
|
||||
|
||||
android {
|
||||
namespace = "win.taptap.musicmanager.client"
|
||||
compileSdk = 35
|
||||
// Google Play requires new apps and updates to target API 36 from
|
||||
// 31 August 2026.
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "win.taptap.musicmanager.client"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "0.1.0"
|
||||
targetSdk = 36
|
||||
versionCode = appVersionCode
|
||||
versionName = appVersionName
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (hasUploadKey) {
|
||||
create("release") {
|
||||
storeFile = uploadKeyStore
|
||||
storePassword = uploadKeyStorePassword
|
||||
keyAlias = uploadKeyAlias
|
||||
keyPassword = uploadKeyPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
if (hasUploadKey) signingConfig = signingConfigs.getByName("release")
|
||||
isMinifyEnabled = false
|
||||
isShrinkResources = false
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build a signed Android App Bundle for the Google Play internal testing track.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/build-release-aab.sh [versionCode] [versionName]
|
||||
#
|
||||
# Signing values are read by Gradle from the environment or local.properties:
|
||||
# UPLOAD_STORE_FILE absolute path to the upload keystore
|
||||
# UPLOAD_STORE_PASSWORD
|
||||
# UPLOAD_KEY_ALIAS
|
||||
# UPLOAD_KEY_PASSWORD
|
||||
#
|
||||
# Play requires a versionCode that is higher than every previous upload.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
GRADLE="${GRADLE:-gradle}"
|
||||
AAB="composeApp/build/outputs/bundle/release/composeApp-release.aab"
|
||||
|
||||
prop() {
|
||||
local key="$1"
|
||||
[ -f local.properties ] || return 0
|
||||
grep -E "^${key}=" local.properties | tail -1 | cut -d= -f2-
|
||||
}
|
||||
|
||||
if [ -z "${ANDROID_KEYSTORE_PATH:-}" ] && [ -z "$(prop UPLOAD_STORE_FILE)" ]; then
|
||||
echo "No upload key configured: set UPLOAD_STORE_FILE in local.properties" >&2
|
||||
echo "or ANDROID_KEYSTORE_PATH in the environment." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION_CODE="${1:-${VERSION_CODE:-$(prop VERSION_CODE)}}"
|
||||
VERSION_NAME="${2:-${VERSION_NAME:-$(prop VERSION_NAME)}}"
|
||||
VERSION_CODE="${VERSION_CODE:-1}"
|
||||
VERSION_NAME="${VERSION_NAME:-0.1.0}"
|
||||
|
||||
export VERSION_CODE VERSION_NAME
|
||||
export ANDROID_HOME="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Android/Sdk}}"
|
||||
|
||||
echo "Building AAB versionCode=$VERSION_CODE versionName=$VERSION_NAME"
|
||||
"$GRADLE" :composeApp:bundleRelease --console=plain
|
||||
|
||||
if ! jarsigner -verify "$AAB" >/dev/null 2>&1; then
|
||||
echo "AAB is not signed; check the upload keystore settings." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Signed bundle: $ROOT/$AAB"
|
||||
sha256sum "$AAB"
|
||||
echo
|
||||
echo "Upload it to Play Console > Testing > Internal testing > Create new release."
|
||||
@@ -14,8 +14,8 @@ let
|
||||
node = pkgs.nodejs_22;
|
||||
|
||||
androidPackages = pkgs.androidenv.composeAndroidPackages {
|
||||
platformVersions = [ "35" ];
|
||||
buildToolsVersions = [ "35.0.0" ];
|
||||
platformVersions = [ "36" ];
|
||||
buildToolsVersions = [ "36.0.0" ];
|
||||
includeEmulator = false;
|
||||
includeSystemImages = false;
|
||||
includeNDK = false;
|
||||
|
||||
Reference in new issue
Block a user