Files
stitch/app/build.gradle.kts
T
thekhalidsha 372190f8ec Stitch 0.4.4: saved chats, model guide, Thinai, sturdier web search
Ideas ported from Thinai (github.com/Aravindargutus/Thinai, MIT); none of
its Flutter code is used directly.

- Chats panel: every conversation saved (ChatStore); new chat, switch,
  search, rename, delete, delete all. Fixes B-38: AI replies were never
  saved and the chat screen started empty after every restart.
- Model guide: 20 real .litertlm models, the phone's RAM/CPU/storage,
  use-case chips, fit and speed estimates (ModelGuide).
- Thinai preset; any AI server on 127.0.0.1 gets short instructions and
  the 33 phone tools instead of 70.
- Web search: DuckDuckGo Lite/HTML then Bing, challenge-page detection,
  10-minute engine rest, relevance filter (B-37).
- Other people's text wrapped with a random id and control tokens
  defused (B-40).
- Wake-phrase service no longer crashes the app after an update or
  reboot; a one-tap notice resumes it (B-39, pre-existing since 0.4.0).
- 37 new tests (87 -> 124); fake AI test server kept in tools-dev/.
- Docs: DEVELOPMENT_HISTORY, README, STAGE_A2_CHECKLIST section 6.
2026-09-28 11:19:58 +05:30

115 lines
4.2 KiB
Kotlin

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)
}
}