Android: wire Firebase google-services.json into the build (client half)
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 <noreply@anthropic.com>
This commit is contained in:
+15
-7
@@ -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: |
|
||||
|
||||
Reference in New Issue
Block a user