// SPDX-FileCopyrightText: 2026 Mohammed Khalid // SPDX-License-Identifier: Apache-2.0 import java.util.Properties plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("org.jetbrains.kotlin.plugin.compose") } android { namespace = "app.stitch" compileSdk = 35 ndkVersion = "30.0.16248370" defaultConfig { applicationId = "app.stitch" minSdk = 28 targetSdk = 35 versionCode = 17 versionName = "0.4.4" ndk { // Needle 2 ships prebuilt engines for these two; together they cover practically every Android phone. abiFilters += listOf("arm64-v8a", "armeabi-v7a") // ./gradlew -Pemulator … also builds x86_64, to test on-device models natively in the emulator. if (project.hasProperty("emulator")) abiFilters += "x86_64" } externalNativeBuild { cmake { arguments += listOf("-DANDROID_STL=c++_static") } } } externalNativeBuild { cmake { path = file("src/main/cpp/CMakeLists.txt") version = "3.22.1" } } // The real release key, kept outside the project at ~/.stitch-release-key/. // // Opt-in with -PreleaseKey. It is NOT the default, because switching signing keys means the new APK // cannot install over an already-installed Stitch: the app has to be uninstalled first, which erases // everything. Do not pass this flag until a backup has been taken in // Settings → Backup & restore. The full cutover is written up in docs/SIGNING.md. val releaseKeyProps = File(System.getProperty("user.home"), ".stitch-release-key/keystore.properties") val useReleaseKey = project.hasProperty("releaseKey") && releaseKeyProps.exists() if (useReleaseKey) { val props = Properties().apply { releaseKeyProps.inputStream().use { load(it) } } signingConfigs.create("release") { storeFile = File(props.getProperty("storeFile")) storePassword = props.getProperty("storePassword") keyAlias = props.getProperty("keyAlias") keyPassword = props.getProperty("keyPassword") } } buildTypes { release { isMinifyEnabled = true isShrinkResources = true proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") // Default stays the debug key so every build keeps installing over the last one. signingConfig = signingConfigs.getByName(if (useReleaseKey) "release" else "debug") } } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } buildFeatures { compose = true } testOptions { unitTests { isIncludeAndroidResources = true } } } dependencies { val composeBom = platform("androidx.compose:compose-bom:2024.12.01") implementation(composeBom) implementation("androidx.compose.ui:ui") implementation("androidx.compose.material3:material3") implementation("androidx.compose.material:material-icons-extended") implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.activity:activity-compose:1.9.3") implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7") implementation("androidx.lifecycle:lifecycle-runtime-compose:2.8.7") implementation("androidx.core:core-ktx:1.15.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0") implementation("com.squareup.okhttp3:okhttp:4.12.0") // On-device LLMs (Gemma 4 etc., .litertlm files: the same engine Google AI Edge Gallery uses). implementation("com.google.ai.edge.litertlm:litertlm-android:0.17.1") testImplementation("junit:junit:4.13.2") testImplementation("org.json:json:20240303") // Lets plain JVM tests use SharedPreferences, so provider settings and backups can be tested // without a device. Added after per-provider keys landed (B-36) — API keys are worth real coverage. testImplementation("org.robolectric:robolectric:4.14.1") testImplementation("androidx.test:core:1.6.1") } kotlin { compilerOptions { jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) } }