Files
memby/app/build.gradle.kts
T

160 lines
6.2 KiB
Kotlin
Raw Permalink Normal View History

2026-07-27 08:22:55 +12:00
import java.util.Properties
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.compose")
id("org.jetbrains.kotlin.plugin.serialization")
}
// Set in gradle.properties (or ~/.gradle/gradle.properties, or -Pmemby.serverUrl=...).
// Blank means "no hardwired server": the setup screen asks the user for an address.
val embyServerUrl: String = (project.findProperty("memby.serverUrl") as String?).orEmpty().trim()
// The Memby gateway container. When set, the client talks to it instead of Emby and
// becomes a thin renderer; blank keeps the direct-to-Emby path above.
val membyGatewayUrl: String = (project.findProperty("memby.gatewayUrl") as String?).orEmpty().trim()
2026-07-27 08:22:55 +12:00
/** Reads a key from local.properties, which is gitignored and holds machine secrets. */
val localProperties = Properties().apply {
val file = rootProject.file("local.properties")
if (file.exists()) {
file.inputStream().use { load(it) }
}
}
fun localProperty(key: String): String? =
localProperties.getProperty(key)?.trim()?.takeIf { it.isNotEmpty() }
android {
namespace = "com.ponzischeme89.memby"
compileSdk = 35
defaultConfig {
// Matches the Kotlin package. Changed from com.mattcohen.embyclientsname at
// v0.1.53: a new applicationId installs as a separate app, so that release
// required uninstalling the old one and signing in again.
applicationId = "com.ponzischeme89.memby"
minSdk = 23
targetSdk = 35
// versionCode is derived from versionName: major*10000 + minor*100 + patch.
// 0.1.53 -> 153. Keep them in step; the in-app updater compares versionName,
// but Android will not install an APK whose versionCode went backwards.
versionCode = 153
versionName = "0.1.53"
buildConfigField("String", "EMBY_SERVER_URL", "\"${embyServerUrl.replace("\"", "\\\"")}\"")
buildConfigField("String", "MEMBY_GATEWAY_URL", "\"${membyGatewayUrl.replace("\"", "\\\"")}\"")
}
2026-07-27 08:22:55 +12:00
// Release signing. Android identifies an app by (applicationId, signing key), so
// every update must be signed with the SAME key — a different one is rejected as a
// different app and forces users to uninstall first. Keep the keystore and these
// credentials off the repo: set them in local.properties (gitignored) or the
// environment. Without them, `assembleRelease` still builds but stays unsigned.
val keystorePath = localProperty("memby.keystore") ?: System.getenv("MEMBY_KEYSTORE")
val hasKeystore = !keystorePath.isNullOrBlank() && file(keystorePath).exists()
signingConfigs {
if (hasKeystore) {
create("release") {
storeFile = file(keystorePath!!)
storePassword = localProperty("memby.keystorePassword") ?: System.getenv("MEMBY_KEYSTORE_PASSWORD")
keyAlias = localProperty("memby.keyAlias") ?: System.getenv("MEMBY_KEY_ALIAS") ?: "memby"
keyPassword = localProperty("memby.keyPassword") ?: System.getenv("MEMBY_KEY_PASSWORD")
}
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
2026-07-27 08:22:55 +12:00
if (hasKeystore) {
signingConfig = signingConfigs.getByName("release")
} else {
logger.warn(
"Memby: no release keystore configured (memby.keystore). " +
"assembleRelease will produce an UNSIGNED apk that cannot be installed. " +
"See README > Distributing builds.",
)
}
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
buildConfig = true
}
lint {
// media3 marks some APIs (e.g. PlayerView) with a Lint-based @UnstableApi
// opt-in check; don't let it fail the build.
abortOnError = false
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
val composeBom = platform("androidx.compose:compose-bom:2024.12.01")
implementation(composeBom)
// Core / lifecycle / activity
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.activity:activity-compose:1.9.3")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.7")
implementation("androidx.savedstate:savedstate-ktx:1.2.1")
// Measurement only: JankStats is enabled by PerformanceMonitor for debug builds.
implementation("androidx.metrics:metrics-performance:1.0.0")
// Compose (versions from BOM)
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.foundation:foundation")
implementation("androidx.compose.material:material-icons-extended")
// Compose for TV
implementation("androidx.tv:tv-material:1.0.0")
// Image loading
implementation("io.coil-kt:coil-compose:2.7.0")
// Networking + JSON
implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
// DataStore (persisted settings)
implementation("androidx.datastore:datastore-preferences:1.1.1")
// Media3 / ExoPlayer for in-app playback
implementation("androidx.media3:media3-exoplayer:1.5.1")
implementation("androidx.media3:media3-exoplayer-hls:1.5.1")
implementation("androidx.media3:media3-ui:1.5.1")
debugImplementation("androidx.compose.ui:ui-tooling")
testImplementation("junit:junit:4.13.2")
}