Skip to content

Native Android client for Spotify, built with Jetpack Compose

Release APKs under clear names, from one build: ARMv8, ARMv7, universal and TV

kota-zo02f5a39a9eef
diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml
index 5bfd4905..4f524007 100644
--- a/.github/workflows/android.yml
+++ b/.github/workflows/android.yml
@@ -110,20 +110,16 @@ jobs:
MYSPOTI_KEY_PASSWORD: ${{ contains(github.ref_name, '-') && secrets.MYSPOTI_KEY_PASSWORD || secrets.MYSPOTI_STABLE_KEY_PASSWORD }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
- # One APK per ABI, same versionCode (a phone installs only its own; the app's update check
- # picks it, UpdateChecker.apkAsset): myspoti-beta-2.2.1-beta.1-arm64-v8a.apk,
- # myspoti-stable-2.2.1-armeabi-v7a.apk... Obtainium filters on the channel and the ABI.
- # Each APK leaves apk/release/, which the next assembleRelease empties.
- CHANNEL=stable; case "$VERSION" in *-*) CHANNEL=beta ;; esac
- mkdir -p app/build/release-apks
- for ABI in arm64-v8a armeabi-v7a; do
- ./gradlew assembleRelease \
- -Pabis="$ABI" \
- -PappVersionName="$VERSION" \
- -PappVersionCode="$((1000 + GITHUB_RUN_NUMBER))" \
- -PupdateRepo="$GITHUB_REPOSITORY"
- mv app/build/outputs/apk/release/app-release.apk "app/build/release-apks/myspoti-$CHANNEL-$VERSION-$ABI.apk"
- done
+ # One build, every APK (ABI splits), same versionCode, named by :app:collectApks:
+ # Myspoti-2.4.0-ARMv8.apk, -ARMv7.apk, -universal.apk, -TV.apk (betas: Myspoti-Beta-...).
+ # The app's update check picks this phone's one (UpdateChecker.apkAsset).
+ # -PlegacyNames: also myspoti-<beta|stable>-<version>-<abi>.apk, the only names the
+ # updater of 2.3.x and earlier (and Obtainium filters set up for them) know.
+ ./gradlew assembleRelease :app:collectApks \
+ -PappVersionName="$VERSION" \
+ -PappVersionCode="$((1000 + GITHUB_RUN_NUMBER))" \
+ -PupdateRepo="$GITHUB_REPOSITORY" \
+ -PlegacyNames
# This version's section of CHANGELOG.md becomes the release description.
- name: Release notes
@@ -142,7 +138,7 @@ jobs:
- uses: softprops/action-gh-release@v3
with:
- files: base/app/build/release-apks/myspoti-*.apk
+ files: base/app/build/release-apks/*.apk
body_path: base/release-notes.md
generate_release_notes: true
# "v2.0.0-beta.1": a pre-release, offered only to beta builds.
diff --git a/README.md b/README.md
index ba675fb1..f48e71fb 100644
--- a/README.md
+++ b/README.md
@@ -44,11 +44,17 @@ Under the hood, the official Spotify Web Player plays the music, hidden inside t
New versions are offered inside the app: one tap downloads and installs them.
-Each release carries one APK per architecture: `arm64-v8a` for almost every phone from the last ten years, `armeabi-v7a` for older or entry-level 32-bit phones (an app such as CPU-Z or Device Info shows which one yours is; when in doubt, take `arm64-v8a`, and if it refuses to install, `armeabi-v7a`). The in-app update picks the right one by itself.
+Each release carries four APKs:
+- `Myspoti-<version>-ARMv8.apk`: almost every phone from the last ten years (64-bit). When in doubt, take this one.
+- `Myspoti-<version>-ARMv7.apk`: older or entry-level 32-bit phones (an app such as CPU-Z or Device Info shows which one yours is; if ARMv8 refuses to install, take this one).
+- `Myspoti-<version>-universal.apk`: both in one, larger.
+- `Myspoti-<version>-TV.apk`: Android TV and Google TV (the same app; on a TV it opens its TV screens).
-Obtainium (add `https://github.com/kota-zo/myspoti`; the stable app and the beta app are two apps and each release carries their APKs named for the channel and the architecture):
-- **Stable** (`app.myspoti.stable`): leave "Include prereleases" off and set the APK filter to `^myspoti-stable-.*-arm64-v8a\.apk$` (or `-armeabi-v7a` on a 32-bit phone).
-- **Beta** (`app.myspoti`): turn "Include prereleases" on and set the APK filter to `^myspoti-beta-.*-arm64-v8a\.apk$` (or `-armeabi-v7a` on a 32-bit phone).
+Betas are `Myspoti-Beta-<version>-...`. The in-app update picks the right one by itself. (The `myspoti-stable-…-arm64-v8a.apk` copies are there for the updater of 2.3 and earlier.)
+
+Obtainium (add `https://github.com/kota-zo/myspoti`; the stable app and the beta app are two apps):
+- **Stable** (`app.myspoti.stable`): leave "Include prereleases" off and set the APK filter to `^Myspoti-[0-9].*-ARMv8\.apk$` (or `-ARMv7`, `-TV`).
+- **Beta** (`app.myspoti`): turn "Include prereleases" on and set the APK filter to `^Myspoti-Beta-.*-ARMv8\.apk$` (or `-ARMv7`, `-TV`).
- Betas are named `<next version>-beta.<n>` (`2.2.1-beta.1`, then `2.2.1-beta.2`...), marked prerelease on GitHub, and always newer than the last stable.
## What you get
diff --git a/base/app/build.gradle.kts b/base/app/build.gradle.kts
index 0565f4db..67fb1afd 100644
--- a/base/app/build.gradle.kts
+++ b/base/app/build.gradle.kts
@@ -14,6 +14,10 @@ val keystoreProperties = Properties().apply {
}
+/** The ABIs a release has an APK for, and how they are named in it (UpdateChecker reads the same names). */
+val RELEASE_ABIS = listOf("arm64-v8a", "armeabi-v7a")
+val ABI_NAMES = mapOf("arm64-v8a" to "ARMv8", "armeabi-v7a" to "ARMv7")
+
android {
namespace = "app.myspoti.engine"
compileSdk = 37
@@ -38,10 +42,8 @@ android {
// GitHub "owner/repo" whose releases the app checks for updates; empty = off
// (local builds). CI sets it to the repository it builds.
buildConfigField("String", "UPDATE_REPO", "\"${(findProperty("updateRepo") as String?) ?: System.getenv("MYSPOTI_UPDATE_REPO") ?: ""}\"")
- ndk {
- // -Pabis=arm64-v8a: a smaller test APK for one phone.
- abiFilters += (findProperty("abis") as String?)?.split(",") ?: listOf("arm64-v8a", "armeabi-v7a")
- }
+ // -Pabis=arm64-v8a: one APK for one phone (the test builds). Without it, the ABI splits below.
+ (findProperty("abis") as String?)?.let { ndk { abiFilters += it.split(",") } }
// On-device tests (codecs): ./gradlew connectedDebugAndroidTest
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@@ -102,6 +104,17 @@ android {
if (!beta) proguardFiles("proguard-strip-logs.pro")
}
}
+ // One build, every APK a release carries (named by collectApks below): one per ABI, and the
+ // universal one (both ABIs). x86 is left out: no phone or TV Myspoti targets runs it.
+ splits {
+ abi {
+ isEnable = findProperty("abis") == null
+ reset()
+ include(*RELEASE_ABIS.toTypedArray())
+ isUniversalApk = true
+ }
+ }
+ packaging { jniLibs { excludes += listOf("lib/x86/**", "lib/x86_64/**") } }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
@@ -176,4 +189,41 @@ dependencies {
-}
\ No newline at end of file
+}
+/**
+ * `./gradlew :app:collectApks` after assembleRelease: the APKs under clear names in
+ * build/release-apks/: Myspoti-2.4.0-ARMv8.apk (64-bit phones, almost all of them),
+ * Myspoti-2.4.0-ARMv7.apk (32-bit), Myspoti-2.4.0-universal.apk (both) and Myspoti-2.4.0-TV.apk
+ * (Android TV: the universal APK, since many TVs run 32-bit apps on a 64-bit chip). Betas are
+ * Myspoti-Beta-..., the optimised dev builds Myspoti-dev-...
+ * -PlegacyNames: also the names the updater of 2.3.x and earlier looks for
+ * (myspoti-<beta|stable>-<version>-<abi>.apk), so those apps still find their update.
+ */
+tasks.register("collectApks") {
+ mustRunAfter("assembleRelease")
+ val version = (findProperty("appVersionName") as String?) ?: "2.3.0"
+ val beta = findProperty("appVersionName") == null || version.contains("-beta")
+ val app = when { findProperty("overDev") != null -> "Myspoti-dev"; beta -> "Myspoti-Beta"; else -> "Myspoti" }
+ val legacy = findProperty("legacyNames") != null
+ // Copies: the configuration cache cannot keep a reference to the script's own values.
+ val abis = RELEASE_ABIS.toList()
+ val abiNames = ABI_NAMES.toMap()
+ val from = layout.buildDirectory.dir("outputs/apk/release")
+ val into = layout.buildDirectory.dir("release-apks")
+ doLast {
+ val src = from.get().asFile
+ val dst = into.get().asFile.apply { deleteRecursively(); mkdirs() }
+ fun copy(name: String, to: String) {
+ val f = src.resolve(name)
+ if (!f.exists()) throw GradleException("$name missing: run assembleRelease without -Pabis first")
+ f.copyTo(dst.resolve(to), overwrite = true)
+ }
+ abis.forEach { abi ->
+ copy("app-$abi-release.apk", "$app-$version-${abiNames.getValue(abi)}.apk")
+ if (legacy) copy("app-$abi-release.apk", "myspoti-${if (beta) "beta" else "stable"}-$version-$abi.apk")
+ }
+ copy("app-universal-release.apk", "$app-$version-universal.apk")
+ copy("app-universal-release.apk", "$app-$version-TV.apk")
+ dst.listFiles()?.sorted()?.forEach { println("${it.name} ${it.length() / 1024 / 1024} MB") }
+ }
+}
diff --git a/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt b/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt
index 9455cd1a..0fe998ea 100644
--- a/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt
+++ b/base/app/src/main/java/com/music/spotui/data/api/UpdateChecker.kt
@@ -119,25 +119,29 @@ object UpdateChecker {
return Release(version, url, prefs.getString("notes", null).orEmpty(), prefs.getString("apk", null).orEmpty()).takeIf { isNewer(version, BuildConfig.VERSION_NAME) }
}
- /** The ABIs a release carries one APK for (`myspoti-<channel>-<version>-<abi>.apk`): no x86, no universal APK. */
- internal val RELEASE_ABIS = listOf("arm64-v8a", "armeabi-v7a")
+ /** The ABIs a release carries one APK for, and their names in it (as app/build.gradle.kts `collectApks`). */
+ internal val RELEASE_ABIS = mapOf("arm64-v8a" to "ARMv8", "armeabi-v7a" to "ARMv7")
/**
- * The release's APK download link for this app's channel and this phone: the CI uploads one
- * `myspoti-<beta|stable>-<version>-<abi>.apk` per ABI of [RELEASE_ABIS], and the first of [abis]
- * (the phone's, most preferred first) that has one wins, so a 64-bit phone that also runs
- * armeabi-v7a takes arm64-v8a. Older releases carry one APK without an ABI,
- * `myspoti-<beta|stable>-<version>.apk` or `myspoti-<version>.apk` (the app's own channel, since [fetch]
- * only offers a release of it), taken as before. Only this channel's APK: a release carrying both
- * must not hand a phone the other channel's build (a different package, it could not update this one),
- * and a name that matches none (or no APK for this phone's ABIs) gives no link.
+ * The release's APK download link for this app's channel and this phone. A release carries
+ * `Myspoti-<version>-ARMv8.apk`, `-ARMv7.apk`, `-universal.apk` and `-TV.apk` (betas:
+ * `Myspoti-Beta-<version>-...`), and the first of [abis] (the phone's, most preferred first)
+ * that has one wins, so a 64-bit phone that also runs armeabi-v7a takes ARMv8. The names of
+ * 2.3.x and before come next: `myspoti-<beta|stable>-<version>-<abi>.apk` (still uploaded for
+ * the apps that only know them), then one APK without an ABI, `myspoti-<beta|stable>-<version>.apk`
+ * or `myspoti-<version>.apk`. Only this channel's APK: a release carrying both must not hand a
+ * phone the other channel's build (a different package, it could not update this one), and a
+ * name that matches none (or no APK for this phone's ABIs) gives no link.
*/
internal fun apkAsset(release: JSONObject, beta: Boolean = isBeta, abis: List<String> = deviceAbis): String {
val assets = release.optJSONArray("assets") ?: return ""
val version = release.optString("tag_name").removePrefix("v")
+ val named = "${if (beta) "Myspoti-Beta" else "Myspoti"}-$version"
val channel = "myspoti-${if (beta) "beta" else "stable"}-$version"
val byName = (0 until assets.length()).map { assets.getJSONObject(it) }.associateBy { it.optString("name") }
- val want = abis.filter { it in RELEASE_ABIS }.map { "$channel-$it.apk" } + listOf("$channel.apk", "myspoti-$version.apk")
+ val ours = abis.filter { it in RELEASE_ABIS }
+ val want = ours.map { "$named-${RELEASE_ABIS.getValue(it)}.apk" } + ours.map { "$channel-$it.apk" } +
+ listOf("$channel.apk", "myspoti-$version.apk")
return want.firstNotNullOfOrNull { byName[it] }?.optString("browser_download_url").orEmpty()
}
diff --git a/base/app/src/test/java/com/music/spotui/data/api/UpdateCheckerTest.kt b/base/app/src/test/java/com/music/spotui/data/api/UpdateCheckerTest.kt
index 2d2d68fc..fde57ad3 100644
--- a/base/app/src/test/java/com/music/spotui/data/api/UpdateCheckerTest.kt
+++ b/base/app/src/test/java/com/music/spotui/data/api/UpdateCheckerTest.kt
@@ -74,4 +74,20 @@ class UpdateCheckerTest {
{"name":"myspoti-stable-2.2.1.apk","browser_download_url":"https://x/stable.apk"}]}""")
assertEquals("https://x/stable.apk", UpdateChecker.apkAsset(single, beta = false, abis = listOf("armeabi-v7a")))
}
+ @Test fun findsTheClearlyNamedApks() {
+ val r = org.json.JSONObject("""{"tag_name":"v2.4.0","assets":[
+ {"name":"Myspoti-2.4.0-TV.apk","browser_download_url":"https://x/tv.apk"},
+ {"name":"Myspoti-2.4.0-universal.apk","browser_download_url":"https://x/universal.apk"},
+ {"name":"Myspoti-2.4.0-ARMv7.apk","browser_download_url":"https://x/v7.apk"},
+ {"name":"Myspoti-2.4.0-ARMv8.apk","browser_download_url":"https://x/v8.apk"},
+ {"name":"myspoti-stable-2.4.0-arm64-v8a.apk","browser_download_url":"https://x/legacy-v8.apk"}]}""")
+ assertEquals("https://x/v8.apk", UpdateChecker.apkAsset(r, beta = false, abis = listOf("arm64-v8a", "armeabi-v7a", "armeabi")))
+ assertEquals("https://x/v7.apk", UpdateChecker.apkAsset(r, beta = false, abis = listOf("armeabi-v7a", "armeabi")))
+ // A stable release has no beta APK.
+ assertEquals("", UpdateChecker.apkAsset(r, beta = true, abis = listOf("arm64-v8a")))
+ val b = org.json.JSONObject("""{"tag_name":"v2.4.0-beta.2","assets":[
+ {"name":"Myspoti-Beta-2.4.0-beta.2-ARMv8.apk","browser_download_url":"https://x/b8.apk"}]}""")
+ assertEquals("https://x/b8.apk", UpdateChecker.apkAsset(b, beta = true, abis = listOf("arm64-v8a")))
+ assertEquals("", UpdateChecker.apkAsset(b, beta = false, abis = listOf("arm64-v8a")))
+ }
}
diff --git a/tools/discord_release.py b/tools/discord_release.py
index 1216002d..e480ab82 100755
--- a/tools/discord_release.py
+++ b/tools/discord_release.py
@@ -46,9 +46,10 @@ def payload(release):
version = tag.removeprefix("v")
url = release["html_url"]
notes = clean_notes(release.get("body")) or "See the release page for details."
- # One APK per ABI: the link goes to arm64-v8a (most phones); older releases have a single one.
+ # One APK per ABI: the link goes to ARMv8 (most phones; arm64-v8a before 2.4); older releases have a single one.
apks = [a for a in release.get("assets", []) if a["name"].endswith(".apk")]
- apk = next((a for a in apks if a["name"].endswith("-arm64-v8a.apk")), apks[0] if apks else None)
+ apk = next((a for a in apks if a["name"].endswith("-ARMv8.apk")),
+ next((a for a in apks if a["name"].endswith("-arm64-v8a.apk")), apks[0] if apks else None))
fields = []
if apk:
size = apk["size"] / 1_048_576