- Three source trees: core/ (shared C++ engine, moved from ios/core), app/ (Android UI), ios/app/ (iOS UI) - Android plays through core/ via JNI (EngineHost, jni_engine.cpp): the Oboe callback renders natively; the Kotlin model is mirrored as project text and applied as a diff, so playback continues through edits - The Kotlin engine moves to the unit tests as ReferenceEngine (golden reference) - Shared MasterRecorder in core/src/host, used by both apps; host_test - versions.properties: one versionName/versionCode for both platforms, continuing Android's numbering (iOS 0.6.0/11 -> 0.37.0/71) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
148 lines
5.6 KiB
Kotlin
148 lines
5.6 KiB
Kotlin
// Build configuration for the single application module. This is where we turn
|
|
// on Compose, set the min/target Android versions, and list dependencies.
|
|
|
|
import java.util.Properties
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.application)
|
|
alias(libs.plugins.kotlin.android)
|
|
alias(libs.plugins.kotlin.compose)
|
|
}
|
|
|
|
// Versions live in //versions.properties so the Makefile and Gradle can never
|
|
// disagree about what is being built or what the published APK is called.
|
|
val appVersions = Properties().apply {
|
|
rootProject.file("versions.properties").inputStream().use { load(it) }
|
|
}
|
|
val appVersionName: String = appVersions.getProperty("versionName").trim()
|
|
val appVersionCode: Int = appVersions.getProperty("versionCode").trim().toInt()
|
|
|
|
android {
|
|
namespace = "cc.tiredsysadmin.android.sizzle"
|
|
compileSdk = 34
|
|
|
|
// Native (Oboe) low-latency output backend; see src/main/cpp.
|
|
// NDK r27+ builds native libs 16 KB-page-aligned by default and ships a
|
|
// 16 KB-aligned libc++_shared.so (required for Android 15 / Google Play).
|
|
ndkVersion = "27.2.12479018"
|
|
|
|
defaultConfig {
|
|
applicationId = "cc.tiredsysadmin.android.sizzle"
|
|
// minSdk 26 (Android 8.0) is the floor for the native MIDI API
|
|
// (android.media.midi) and AAudio low-latency audio we rely on.
|
|
minSdk = 26
|
|
targetSdk = 34
|
|
versionCode = appVersionCode
|
|
versionName = appVersionName
|
|
|
|
// We provide our own instrumentation runner if/when tests are added.
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
externalNativeBuild {
|
|
cmake { arguments += "-DANDROID_STL=c++_shared" }
|
|
}
|
|
}
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
path = file("src/main/cpp/CMakeLists.txt")
|
|
version = "3.22.1"
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
// Shrinking is off by default so newcomers get readable stack traces.
|
|
// Flip to true once the app stabilises.
|
|
isMinifyEnabled = false
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro",
|
|
)
|
|
}
|
|
|
|
// A realistic-performance "staging" variant for testing UI responsiveness
|
|
// on-device. The `debug` build is `debuggable = true`, which makes ART run
|
|
// the app un-optimised and makes Compose several times slower — so measuring
|
|
// UI "snappiness" on a debug build is misleading. This variant flips
|
|
// debuggability off (the single biggest perf lever) while reusing the debug
|
|
// signing key, so it still installs without a release keystore. R8/shrinking
|
|
// stays off to avoid needing JNI/Compose keep-rules for now.
|
|
create("staging") {
|
|
initWith(getByName("debug"))
|
|
isDebuggable = false
|
|
isJniDebuggable = false
|
|
signingConfig = signingConfigs.getByName("debug")
|
|
matchingFallbacks += "debug"
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
}
|
|
|
|
buildFeatures {
|
|
compose = true
|
|
prefab = true // exposes the Oboe AAR's native headers/lib to CMake
|
|
}
|
|
|
|
packaging {
|
|
resources.excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
}
|
|
}
|
|
|
|
// Give the release APK a predictable, versionCode-stamped name so it drops straight
|
|
// into the private F-Droid repo: cc.tiredsysadmin.android.sizzle_<versionCode>.apk. Uses
|
|
// the legacy variant API (the Kotlin-DSL `android {}` receiver doesn't expose it).
|
|
(extensions.getByName("android") as com.android.build.gradle.AbstractAppExtension)
|
|
.applicationVariants.all {
|
|
if (buildType.name == "release") {
|
|
val vc = versionCode
|
|
outputs.all {
|
|
(this as com.android.build.gradle.internal.api.BaseVariantOutputImpl)
|
|
.outputFileName = "${applicationId}_$vc.apk"
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(libs.androidx.core.ktx)
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
|
implementation(libs.androidx.activity.compose)
|
|
|
|
// Compose UI toolkit — the BOM keeps every Compose artifact on one version.
|
|
implementation(platform(libs.androidx.compose.bom))
|
|
implementation(libs.androidx.compose.ui)
|
|
implementation(libs.androidx.compose.ui.graphics)
|
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
|
implementation(libs.androidx.compose.foundation)
|
|
implementation(libs.androidx.compose.material3)
|
|
implementation(libs.androidx.compose.material.icons.extended)
|
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
|
|
|
// Background playback + media-style notification transport controls.
|
|
implementation(libs.androidx.media3.session)
|
|
implementation(libs.androidx.media3.common)
|
|
|
|
// Persistence for settings & themes.
|
|
implementation(libs.androidx.datastore.preferences)
|
|
|
|
// Coroutines for the audio/sequencer background work.
|
|
implementation(libs.kotlinx.coroutines.android)
|
|
|
|
// Oboe: low-latency native audio (AAudio) — the native output backend.
|
|
// 1.9.3+ ships 16 KB-page-aligned .so files (required by Android 15 / Play).
|
|
implementation("com.google.oboe:oboe:1.10.0")
|
|
|
|
// JVM unit tests for the pure model/io logic (no device needed).
|
|
testImplementation("junit:junit:4.13.2")
|
|
// Virtual-time coroutine testing (drives the input hold-to-repeat schedule).
|
|
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
|
|
}
|