Fix android backend url

This commit is contained in:
2026-03-30 00:03:27 -06:00
parent 467daa35f0
commit 8f05f22b23
3 changed files with 48 additions and 10 deletions

View File

@@ -1,7 +1,23 @@
import java.util.Properties
plugins {
alias(libs.plugins.android.application)
}
val localProperties = Properties().apply {
val file = rootProject.file("local.properties")
if (file.exists()) {
file.inputStream().use { load(it) }
}
}
fun quoted(value: String): String = "\"$value\""
val emulatorBackendUrl =
(localProperties.getProperty("petstore.backend.emulatorUrl") ?: "http://10.0.2.2:8080/").trim()
val deviceBackendUrl =
(localProperties.getProperty("petstore.backend.deviceUrl") ?: "http://10.0.0.200:8080/").trim()
android {
namespace = "com.example.petstoremobile"
compileSdk = 36
@@ -14,6 +30,13 @@ android {
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "EMULATOR_BACKEND_URL", quoted(emulatorBackendUrl))
buildConfigField("String", "DEVICE_BACKEND_URL", quoted(deviceBackendUrl))
}
buildFeatures {
buildConfig = true
}
buildTypes {
@@ -62,4 +85,4 @@ dependencies {
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
}
}