116 lines
3.6 KiB
Kotlin
116 lines
3.6 KiB
Kotlin
import java.util.Properties
|
|
import java.io.File
|
|
import java.io.FileInputStream
|
|
import java.io.FileOutputStream
|
|
|
|
plugins {
|
|
id("com.android.application")
|
|
id("org.jetbrains.kotlin.android")
|
|
}
|
|
|
|
fun getBuildNumber(): Int {
|
|
val versionFile = file("version.properties")
|
|
val properties = Properties()
|
|
|
|
if (versionFile.exists()) {
|
|
properties.load(FileInputStream(versionFile))
|
|
}
|
|
|
|
val buildNumber = (properties.getProperty("build.number") ?: "0").toInt() + 1
|
|
|
|
properties.setProperty("build.number", buildNumber.toString())
|
|
properties.store(FileOutputStream(versionFile), "Auto-incremented Build Number")
|
|
|
|
return buildNumber
|
|
}
|
|
|
|
android {
|
|
namespace = "com.habitforge.companion"
|
|
compileSdk = 35
|
|
|
|
defaultConfig {
|
|
applicationId = "com.habitforge.companion"
|
|
minSdk = 28 // Health Connect requires Android 9+
|
|
targetSdk = 34
|
|
|
|
val buildNum = getBuildNumber()
|
|
versionCode = buildNum
|
|
versionName = "1.0.0.$buildNum"
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
// Backend URL - change this to your server address
|
|
buildConfigField("String", "BACKEND_URL", "\"http://10.0.2.2:8000\"") // 10.0.2.2 = localhost from emulator
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro"
|
|
)
|
|
// For production, change this to your actual server URL
|
|
buildConfigField("String", "BACKEND_URL", "\"https://your-habitforge-server.com\"")
|
|
}
|
|
debug {
|
|
buildConfigField("String", "BACKEND_URL", "\"http://10.0.2.2:8000\"")
|
|
}
|
|
}
|
|
|
|
applicationVariants.all {
|
|
val variant = this
|
|
outputs.all {
|
|
(this as? com.android.build.gradle.internal.api.BaseVariantOutputImpl)?.outputFileName = "HabitForge-companion-v${variant.versionName}.apk"
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
}
|
|
|
|
buildFeatures {
|
|
viewBinding = true
|
|
buildConfig = true
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
// Core Android
|
|
implementation("androidx.core:core-ktx:1.12.0")
|
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
|
implementation("com.google.android.material:material:1.11.0")
|
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
|
implementation("androidx.activity:activity-ktx:1.8.2")
|
|
|
|
// Health Connect SDK
|
|
implementation("androidx.health.connect:connect-client:1.1.0-alpha10")
|
|
|
|
// WorkManager for background sync
|
|
implementation("androidx.work:work-runtime-ktx:2.9.0")
|
|
|
|
// Networking
|
|
implementation("com.squareup.retrofit2:retrofit:2.9.0")
|
|
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
|
|
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
|
|
|
|
// Coroutines
|
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
|
|
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
|
|
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
|
|
|
|
// DataStore for preferences
|
|
implementation("androidx.datastore:datastore-preferences:1.0.0")
|
|
|
|
// Testing
|
|
testImplementation("junit:junit:4.13.2")
|
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
|
}
|