Recently Written · git

subread-android

SubRead for Android: times an audiobook against its ebook on the device

git clone https://github.com/equwal/subread-android

Log | Files | Refs


app/build.gradle.kts (4504 bytes)

1 plugins {
2     alias(libs.plugins.android.application)
3     alias(libs.plugins.kotlin.compose)
4 }
5 
6 // Release signing comes from the environment, so the key never lives in the
7 // repository. CI supplies it from repository secrets; without it the release
8 // build is simply left unsigned.
9 val keystorePath = providers.environmentVariable("SUBREAD_KEYSTORE_FILE").orNull
10 val keystorePassword = providers.environmentVariable("SUBREAD_KEYSTORE_PASSWORD").orNull
11 val signingReady = !keystorePath.isNullOrBlank() && !keystorePassword.isNullOrBlank() &&
12     file(keystorePath).isFile
13 
14 android {
15     namespace = "space.subread.app"
16     compileSdk = 36
17     ndkVersion = "29.0.14206865"
18 
19     // No list of dependencies, encrypted for Google alone, inside the app: F-Droid
20     // does not accept a part of the app that nobody else can read.
21     dependenciesInfo {
22         includeInApk = false
23         includeInBundle = false
24     }
25 
26     defaultConfig {
27         applicationId = "space.subread.app"
28         minSdk = 26
29         targetSdk = 36
30         // Plain numbers, in this file: F-Droid reads them from here to find a new release.
31         versionCode = 14
32         versionName = "0.9.4"
33         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
34 
35         // A link to the Ko-fi page. Google Play is not given it (-PplayStore=true): its
36         // rules on payments outside the store are read differently by each reviewer, and
37         // a first listing is not the place to find out. F-Droid and GitHub builds have it.
38         buildConfigField("boolean", "DONATE_LINK", (providers.gradleProperty("playStore").orNull != "true").toString())
39         // A link to honjimaku.com, a library of subtitles that users share. Not for Google Play either.
40         buildConfigField("boolean", "HONJIMAKU_LINK", (providers.gradleProperty("playStore").orNull != "true").toString())
41 
42         // Every phone worth transcribing on is 64-bit ARM; the speech library
43         // is built for ARMv8.2 specifically (see src/main/cpp/CMakeLists.txt).
44         ndk { abiFilters += "arm64-v8a" }
45         externalNativeBuild {
46             cmake { arguments += listOf("-DANDROID_STL=c++_static") }
47         }
48     }
49 
50     if (signingReady) {
51         signingConfigs {
52             create("release") {
53                 storeFile = file(keystorePath!!)
54                 storePassword = keystorePassword
55                 keyAlias = "subread"
56                 keyPassword = keystorePassword
57             }
58         }
59     }
60 
61     buildTypes {
62         debug { applicationIdSuffix = ".debug" }
63         release {
64             // R8 removes unused code and resources. F-Droid asks for it. The JNI
65             // methods of Whisper keep their names through the default rules.
66             isMinifyEnabled = true
67             isShrinkResources = true
68             proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
69             if (signingReady) signingConfig = signingConfigs.getByName("release")
70         }
71     }
72 
73     compileOptions {
74         sourceCompatibility = JavaVersion.VERSION_17
75         targetCompatibility = JavaVersion.VERSION_17
76     }
77     buildFeatures {
78         compose = true
79         buildConfig = true
80     }
81 
82     externalNativeBuild {
83         cmake {
84             path = file("src/main/cpp/CMakeLists.txt")
85             version = "3.31.6"
86         }
87     }
88 
89     // The model is copied out of the APK to a real file on first run; storing
90     // it uncompressed makes that a straight copy.
91     androidResources { noCompress += "bin" }
92 
93     lint { abortOnError = false }
94 }
95 
96 dependencies {
97     implementation(project(":core"))
98     implementation(platform(libs.androidx.compose.bom))
99     implementation(libs.androidx.activity.compose)
100     implementation(libs.androidx.compose.material3)
101     implementation(libs.androidx.compose.ui)
102     implementation(libs.androidx.compose.ui.graphics)
103     implementation(libs.androidx.core.ktx)
104     implementation(libs.androidx.lifecycle.runtime.ktx)
105     implementation(libs.androidx.lifecycle.runtime.compose)
106     implementation(libs.kotlinx.coroutines.android)
107     // The intent API decides on plain strings, so JUnit alone tests it on a laptop.
108     testImplementation(libs.junit)
109     androidTestImplementation(libs.androidx.test.runner)
110     androidTestImplementation(libs.androidx.test.junit)
111     androidTestImplementation(platform(libs.androidx.compose.bom))
112     androidTestImplementation(libs.androidx.compose.ui.test.junit4)
113     debugImplementation(libs.androidx.compose.ui.test.manifest)
114 }