Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,27 @@ kotlin-app/
- JDK 17
- Android SDK 35

### Firebase setup

`app/google-services.json` is gitignored — real Firebase config never enters version control. A committed `app/google-services.json.template` carries stub values that pass AGP's `processGoogleServices` task so fresh checkouts build cleanly. Runtime Firebase calls (FCM, Crashlytics) no-op until you supply a real config.

To supply a real Firebase config on your machine:

```bash
# Option A — drop the file directly (preferred for daily dev)
cp /path/to/your-google-services.json app/google-services.json

# Option B — point Gradle at a config that lives elsewhere
./gradlew assembleDebug -Pfirebase.config.path=/abs/path/to/google-services.json
```

The materialised `app/google-services.json` stays gitignored. CI passes the build path via the `FIREBASE_CONFIG_PATH` secret (mapped to `firebase.config.path` Gradle property in the release workflow).

### Setup

1. Clone the repository:
```bash
git clone https://github.com/your-org/kotlin-app.git
git clone https://github.com/databayt/android-app.git
cd kotlin-app
```

Expand Down
37 changes: 37 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,43 @@ plugins {
alias(libs.plugins.firebase.crashlytics)
}

// E01.S01: Materialise app/google-services.json before AGP's googleServices
// plugin needs it. Real Firebase config stays gitignored — `.template` ships a
// stub that lets `:app:processDebugGoogleServices` succeed on a fresh checkout
// (runtime Firebase calls fail gracefully via AppStartupInitializer.confirmFirebase).
//
// Override on a developer machine with:
// ./gradlew assembleDebug -Pfirebase.config.path=/abs/path/to/google-services.json
// Or drop the real file at app/google-services.json (stays out of git).
run {
val target = file("google-services.json")
if (target.exists()) return@run

val overridePath = providers.gradleProperty("firebase.config.path").orNull
val template = file("google-services.json.template")
val source = when {
overridePath != null -> file(overridePath).also {
require(it.exists()) {
"firebase.config.path points to $overridePath but the file does not exist."
}
}
template.exists() -> {
logger.warn(
"[E01.S01] Using google-services.json.template (stub Firebase config). " +
"FCM + Crashlytics will not deliver until a real config is provided. " +
"See README.md → Firebase setup."
)
template
}
else -> error(
"No google-services.json available. Either drop one at app/google-services.json, " +
"pass -Pfirebase.config.path=/abs/path, or restore app/google-services.json.template. " +
"See README.md → Firebase setup."
)
}
source.copyTo(target, overwrite = false)
}

android {
namespace = "org.hogwarts.android"
compileSdk = 35
Expand Down
48 changes: 48 additions & 0 deletions app/google-services.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"project_info": {
"project_number": "000000000000",
"project_id": "hogwarts-android-stub",
"storage_bucket": "hogwarts-android-stub.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:000000000000:android:0000000000000000000000",
"android_client_info": {
"package_name": "org.hogwarts.android"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyA0000000000000000000000000000000000"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:000000000000:android:1111111111111111111111",
"android_client_info": {
"package_name": "org.hogwarts.android.debug"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyA0000000000000000000000000000000000"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}