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:
@@ -50,3 +50,7 @@ Thumbs.db
|
|||||||
# Editor
|
# Editor
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
# Firebase service-account keys (SECRET private key — NEVER commit)
|
||||||
|
**/*firebase-adminsdk*.json
|
||||||
|
**/*service-account*.json
|
||||||
|
|||||||
+15
-7
@@ -218,16 +218,24 @@ workflows:
|
|||||||
# camera/mic/notification permissions the web UI needs (mirrors ios-patch.sh for iOS). Tolerant + idempotent.
|
# 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
|
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: |
|
script: |
|
||||||
cd mobile/android/app
|
# Place the client Firebase config into android/app/ so the google-services Gradle plugin applies and
|
||||||
if [ -n "$GOOGLE_SERVICES_JSON" ]; then
|
# FirebaseApp initializes at runtime — WITHOUT it, PushNotifications.register() throws
|
||||||
# Portable decode: GNU coreutils uses --decode/-d, BSD/macOS base64 uses -D.
|
# "Default FirebaseApp is not initialized" and crashes the app on Android. Prefer the committed file;
|
||||||
echo "$GOOGLE_SERVICES_JSON" | { base64 --decode 2>/dev/null || base64 -D; } > google-services.json
|
# fall back to a base64 GOOGLE_SERVICES_JSON env var. (Runs from the repo root; the Android project was
|
||||||
echo "google-services.json written — FCM push enabled in this build"
|
# 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
|
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
|
fi
|
||||||
|
ls -l "$DEST" 2>/dev/null || echo "(no google-services.json placed)"
|
||||||
|
|
||||||
- name: Build the debug APK
|
- name: Build the debug APK
|
||||||
script: |
|
script: |
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user