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.

local.properties is a standard Android convention for storing machine-specific and sensitive values that must not be checked into source control. La Previa Restobar extends this convention by reading the Firebase API key from this file at Gradle configuration time and embedding it as a BuildConfig field, making it available to the app at runtime without ever appearing in any versioned file.

What local.properties is and why it is git-ignored

The Android Gradle Plugin has always used local.properties to store the path to the local Android SDK installation (sdk.dir). La Previa Restobar adds one extra property to that file: firebase.api.key. Because this value is secret, the file is listed in .gitignore — anyone who clones the repository must create their own copy before building. A safe template is provided at the repository root as local.properties.example:
local.properties.example
# Template for local.properties
# Copy this file to local.properties and fill in the values

# Firebase API Key (found in google-services.json -> api_key -> current_key)
firebase.api.key=YOUR_API_KEY_HERE
Never replace YOUR_API_KEY_HERE with a real key inside local.properties.example and commit it. The .example file is intentionally a template — only the untracked local.properties file should contain real secrets. Leaking a Firebase API key in a public repository exposes your backend to unauthorized access.

How build.gradle.kts reads local.properties

At the very top of the android {} block in app/build.gradle.kts, Gradle loads the file into a Properties object before any build type is evaluated:
app/build.gradle.kts
import java.util.Properties

android {
    // ...

    val localProperties = Properties()
    val localPropertiesFile = rootProject.file("local.properties")
    if (localPropertiesFile.exists()) {
        localProperties.load(localPropertiesFile.inputStream())
    }
The if (localPropertiesFile.exists()) guard means the build will not fail when the file is absent — instead the property returns an empty string. This is intentional: CI environments provide the key through a different mechanism (see below).

How FIREBASE_API_KEY is injected as a BuildConfig field

Every build type calls buildConfigField to embed the resolved value as a compile-time String constant:
app/build.gradle.kts
buildConfigField(
    "String", "FIREBASE_API_KEY",
    "\"${localProperties.getProperty("firebase.api.key") ?: ""}\""
)
This pattern is identical in all three build types (debug, staging, release). At runtime the app accesses the key through the generated class:
val apiKey = BuildConfig.FIREBASE_API_KEY
Because the value is resolved at Gradle configuration time and baked into the compiled bytecode, it is never stored in a resource file, an assets folder, or a strings.xml entry where it could be extracted from an unsigned APK.

CI/CD: GitHub Secrets

Local developers use local.properties, but the GitHub Actions workflow never has access to that file — it does not exist in the repository. Two GitHub Secrets replace it in CI:

GOOGLE_SERVICES_JSON

The full JSON content of app/google-services.json. The workflow writes this secret to disk before the build step so the Google Services plugin can find it.

FIREBASE_API_KEY

The same key that goes in local.properties (api_key → current_key inside google-services.json). The workflow writes this into local.properties so Gradle can inject it via buildConfigField.

Configuring the secrets

1

Open your repository settings

Navigate to your repository on GitHub and click Settings in the top navigation bar.
2

Open the Secrets panel

In the left sidebar, select Secrets and variables → Actions, then click New repository secret.
3

Add GOOGLE_SERVICES_JSON

  • Name: GOOGLE_SERVICES_JSON
  • Secret: Open app/google-services.json locally, select all, and paste the entire JSON blob.
4

Add FIREBASE_API_KEY

  • Name: FIREBASE_API_KEY
  • Secret: The value of current_key found inside the api_key array in google-services.json. This is exactly the same string you would put after firebase.api.key= in your local local.properties.
GitHub Secrets are masked in workflow logs — even if a step accidentally prints the value, GitHub replaces it with ***. Never hard-code either secret directly in a workflow YAML file.

First-time local setup

1

Copy the example file

From the repository root, create your own local.properties from the template:
cp local.properties.example local.properties
2

Find your Firebase API key

Open app/google-services.json (which you downloaded from the Firebase console — see Firebase Setup). Locate the api_key array and copy the value of current_key:
"api_key": [
  {
    "current_key": "AIzaSy..."
  }
]
3

Paste the key into local.properties

Open local.properties and replace the placeholder:
local.properties
sdk.dir=/Users/you/Library/Android/sdk
firebase.api.key=AIzaSy...
4

Sync and build

In Android Studio, click File → Sync Project with Gradle Files. The BuildConfig.FIREBASE_API_KEY field will now contain your key for all three build variants. Press Run ▶ to verify the build succeeds.

Build docs developers (and LLMs) love