Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/luisumit/LaPreviaRestobar/llms.txt

Use this file to discover all available pages before exploring further.

La Previa Restobar ships three build types — debug, staging, and release — each targeting a different backend environment. Rather than switching URLs at runtime through a shared configuration file, every endpoint is baked into a generated BuildConfig class at compile time, so there is no risk of a debug build accidentally hitting the production API. The sections below explain each variant, the SDK versions used across all of them, and how to switch between them in Android Studio.

SDK and versioning baseline

All three build types share the same SDK configuration defined in the defaultConfig block of app/build.gradle.kts:
SettingValue
compileSdk35
minSdk24 (Android 7.0+)
targetSdk35
applicationIdcom.laprevia.restobar
versionCode and versionName are driven by the GITHUB_RUN_NUMBER environment variable so that every CI build automatically produces a unique, incrementing version number:
app/build.gradle.kts
versionCode = System.getenv("GITHUB_RUN_NUMBER")?.toInt() ?: 1
versionName = "1.0.${System.getenv("GITHUB_RUN_NUMBER") ?: "0"}"
When building locally GITHUB_RUN_NUMBER is not set, so versionCode falls back to 1 and versionName to 1.0.0.

Build types

debug

Targets the Android emulator. Cleartext HTTP allowed. No code shrinking. BuildConfig.DEBUG = true.

staging

Targets a physical device on the local network. Signed with the debug keystore. No code shrinking. Separate application ID suffix.

release

Targets the production API over HTTPS/WSS. R8 minification and resource shrinking enabled. No debug logging.

debug

The debug variant is intended for development on the Android Emulator. The emulator’s loopback address (10.0.2.2) is used as the backend host, mapping to localhost on the development machine. A PHYSICAL_BASE_URL field is also injected for developers who switch between emulator and physical device during the same session.
app/build.gradle.kts
debug {
    versionNameSuffix = "-DEBUG"
    isDebuggable = true
    isMinifyEnabled = false
    buildConfigField("String", "ENVIRONMENT", "\"DEBUG\"")
    buildConfigField("String", "BASE_URL", "\"http://10.0.2.2:8080/\"")
    buildConfigField("String", "PHYSICAL_BASE_URL", "\"http://192.168.0.104:8080/\"")
    buildConfigField("String", "WS_URL", "\"ws://10.0.2.2:8080/ws\"")
    buildConfigField("String", "PHYSICAL_WS_URL", "\"ws://192.168.0.104:8080/ws\"")
    buildConfigField(
        "String", "FIREBASE_API_KEY",
        "\"${localProperties.getProperty("firebase.api.key") ?: ""}\""
    )
}
NetworkModule uses android.os.Build fingerprint heuristics at runtime to detect whether the app is running on an emulator and automatically selects BASE_URL or PHYSICAL_BASE_URL accordingly — no manual toggle needed.

staging

The staging variant is designed for testing on a physical device connected to the same Wi-Fi network as the development machine (192.168.0.104). It gets a distinct application ID suffix (.staging) so it can be installed alongside the release variant on the same device.
app/build.gradle.kts
create("staging") {
    applicationIdSuffix = ".staging"
    versionNameSuffix = "-STAGING"
    isDebuggable = true
    isMinifyEnabled = false
    signingConfig = signingConfigs.getByName("debug")
    buildConfigField("String", "ENVIRONMENT", "\"STAGING\"")
    buildConfigField("String", "BASE_URL", "\"http://192.168.0.104:8080/\"")
    buildConfigField("String", "PHYSICAL_BASE_URL", "\"http://192.168.0.104:8080/\"")
    buildConfigField("String", "WS_URL", "\"ws://192.168.0.104:8080/ws\"")
    buildConfigField("String", "PHYSICAL_WS_URL", "\"ws://192.168.0.104:8080/ws\"")
    buildConfigField(
        "String", "FIREBASE_API_KEY",
        "\"${localProperties.getProperty("firebase.api.key") ?: ""}\""
    )
}
Both BASE_URL and PHYSICAL_BASE_URL point to the same local IP because a physical device can never reach the emulator loopback address.

release

The release variant connects to the production API at api.laprevia.com over HTTPS and secure WebSockets. R8 (isMinifyEnabled = true) obfuscates the bytecode and isShrinkResources = true strips unused resources, reducing APK size. OkHttp logging is automatically disabled in release builds because BuildConfig.DEBUG is false.
app/build.gradle.kts
release {
    isDebuggable = false
    isMinifyEnabled = true
    isShrinkResources = true
    signingConfig = signingConfigs.getByName("debug") // ← agregado
    buildConfigField("String", "ENVIRONMENT", "\"RELEASE\"")
    buildConfigField("String", "BASE_URL", "\"https://api.laprevia.com/\"")
    buildConfigField("String", "PHYSICAL_BASE_URL", "\"https://api.laprevia.com/\"")
    buildConfigField("String", "WS_URL", "\"wss://api.laprevia.com/ws\"")
    buildConfigField("String", "PHYSICAL_WS_URL", "\"wss://api.laprevia.com/ws\"")
    buildConfigField(
        "String", "FIREBASE_API_KEY",
        "\"${localProperties.getProperty("firebase.api.key") ?: ""}\""
    )
    proguardFiles(
        getDefaultProguardFile("proguard-android-optimize.txt"),
        "proguard-rules.pro"
    )
}

BuildConfig fields reference

The table below summarises every buildConfigField injected per variant:
Fielddebugstagingrelease
ENVIRONMENT"DEBUG""STAGING""RELEASE"
BASE_URLhttp://10.0.2.2:8080/http://192.168.0.104:8080/https://api.laprevia.com/
PHYSICAL_BASE_URLhttp://192.168.0.104:8080/http://192.168.0.104:8080/https://api.laprevia.com/
WS_URLws://10.0.2.2:8080/wsws://192.168.0.104:8080/wswss://api.laprevia.com/ws
PHYSICAL_WS_URLws://192.168.0.104:8080/wsws://192.168.0.104:8080/wswss://api.laprevia.com/ws
FIREBASE_API_KEYfrom local.propertiesfrom local.propertiesfrom local.properties
NetworkModule reads these fields directly via BuildConfig:
app/src/main/java/com/laprevia/restobar/di/NetworkModule.kt
private val BASE_URL = BuildConfig.BASE_URL
private val PHYSICAL_BASE_URL = BuildConfig.PHYSICAL_BASE_URL
private val WS_URL = BuildConfig.WS_URL
private val PHYSICAL_WS_URL = BuildConfig.PHYSICAL_WS_URL

Network security configuration

Android blocks cleartext (HTTP) traffic by default. The network_security_config.xml resource explicitly permits it for the three local hosts used by debug and staging builds, while leaving all other traffic restricted to HTTPS:
app/src/main/res/xml/network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <!-- Allow HTTP for local development hosts only -->
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">192.168.0.104</domain>
        <domain includeSubdomains="true">10.0.2.2</domain>
        <domain includeSubdomains="true">localhost</domain>
    </domain-config>
</network-security-config>
Cleartext traffic is permitted only for the three local addresses listed above. Any domain not matched by a <domain-config> block — including api.laprevia.com — is governed by the platform default, which enforces HTTPS on API level 28 and above.

Switching build variants in Android Studio

1

Open the Build Variants panel

In Android Studio, go to View → Tool Windows → Build Variants (or click the Build Variants tab in the bottom-left toolbar).
2

Select the active variant

In the Build Variant column next to the :app module, choose one of:
  • debug — emulator development
  • staging — physical device on local network
  • release — production build
Android Studio will re-sync the project and generate the corresponding BuildConfig class.
3

Run or build

Press Run ▶ to deploy the selected variant to a connected device or emulator, or use Build → Build Bundle(s) / APK(s) to produce an artifact.For a release APK from the command line:
./gradlew assembleRelease
For a staging APK:
./gradlew assembleStaging

Build docs developers (and LLMs) love