From c013536e2bf081400d0b3f2acb91a9551eba44db Mon Sep 17 00:00:00 2001 From: sravan Date: Thu, 17 Sep 2026 19:22:22 +0530 Subject: [PATCH] Android: wire Firebase google-services.json into the build (client half) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit the client Firebase config (bizgaze-connect, package com.bizgaze.connect) and have the Codemagic Android step copy it into android/app/ so the google-services Gradle plugin applies and FirebaseApp initializes — fixing the root cause of the "Default FirebaseApp is not initialized" crash. google-services.json is client-side (ships in the APK), safe for this private repo. The service-account key stays OUT of git (.gitignore: *firebase-adminsdk*.json / *service-account*.json) — it goes on the server as FCM_SERVICE_ACCOUNT separately. Co-Authored-By: Claude Opus 4.8 --- .gitignore | 4 +++ codemagic.yaml | 22 +++++++++----- .../google-services.json | 29 +++++++++++++++++++ 3 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 mobile/FirebaseAccount_Google/google-services.json diff --git a/.gitignore b/.gitignore index fca2b26..1f18998 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,7 @@ Thumbs.db # Editor .vscode/ .idea/ + +# Firebase service-account keys (SECRET private key — NEVER commit) +**/*firebase-adminsdk*.json +**/*service-account*.json diff --git a/codemagic.yaml b/codemagic.yaml index 18f226e..5277562 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -218,16 +218,24 @@ workflows: # camera/mic/notification permissions the web UI needs (mirrors ios-patch.sh for iOS). Tolerant + idempotent. node scripts/android-patch.js android/app/src/main/AndroidManifest.xml - - name: (Optional) Firebase google-services.json for FCM push + - name: Firebase google-services.json for FCM push script: | - cd mobile/android/app - if [ -n "$GOOGLE_SERVICES_JSON" ]; then - # Portable decode: GNU coreutils uses --decode/-d, BSD/macOS base64 uses -D. - echo "$GOOGLE_SERVICES_JSON" | { base64 --decode 2>/dev/null || base64 -D; } > google-services.json - echo "google-services.json written — FCM push enabled in this build" + # Place the client Firebase config into android/app/ so the google-services Gradle plugin applies and + # FirebaseApp initializes at runtime — WITHOUT it, PushNotifications.register() throws + # "Default FirebaseApp is not initialized" and crashes the app on Android. Prefer the committed file; + # fall back to a base64 GOOGLE_SERVICES_JSON env var. (Runs from the repo root; the Android project was + # generated in the previous step.) + DEST=mobile/android/app/google-services.json + if [ -f mobile/FirebaseAccount_Google/google-services.json ]; then + cp mobile/FirebaseAccount_Google/google-services.json "$DEST" + echo "google-services.json copied from repo → FCM enabled" + elif [ -n "$GOOGLE_SERVICES_JSON" ]; then + echo "$GOOGLE_SERVICES_JSON" | { base64 --decode 2>/dev/null || base64 -D; } > "$DEST" + echo "google-services.json written from env → FCM enabled" else - echo "No GOOGLE_SERVICES_JSON set — building WITHOUT FCM push (fine for a shell/UI test build)" + echo "No google-services.json found — building WITHOUT FCM push" fi + ls -l "$DEST" 2>/dev/null || echo "(no google-services.json placed)" - name: Build the debug APK script: | diff --git a/mobile/FirebaseAccount_Google/google-services.json b/mobile/FirebaseAccount_Google/google-services.json new file mode 100644 index 0000000..3b29529 --- /dev/null +++ b/mobile/FirebaseAccount_Google/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "860472998800", + "project_id": "bizgaze-connect", + "storage_bucket": "bizgaze-connect.firebasestorage.app" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:860472998800:android:107cc0fc6936d6898dd115", + "android_client_info": { + "package_name": "com.bizgaze.connect" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyB6gSqIDYr21GKYA4c1e7plUBQMXIcX1Dw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file