How to use secret in app.json.android.googleServicesFile? EAS build

-Managed
-eas-cli@0.36.1

I have created app-specific secret following: Environment variables and secrets - Expo Documentation. I saved google-services.json file in base64 format and named it as
google_services_base64

Then I used Pre-install hook as explained here: EAS Build: how to include non-Git (private) files, eg google-services.json.
"eas-build-pre-install": "echo $google_services_base64 | base64 -d > google-service.json",

My problem now is that how can I use this secret in app.json: expo.android.googleServicesFile
I have tried to build it: Pre-install hook goes through but build fails in Prebuild:


Prebuilding managed project
- Creating native project directories (./ios and ./android) and updating .gitignore
✔ Created native project
- Adding Metro bundler config
✔ Added Metro config
- Updating your package.json scripts, dependencies, and main file
✔ Updated package.json and added index.js entry point for iOS and Android
- Config syncing
✖ Config sync failed
10[stderr] [07:57:36] [android.dangerous]: withAndroidDangerousBaseMod: Cannot copy google-services.json from /build/workingdir/build/google_services_base64 to /build/workingdir/build/android/app/google-services.json. Please make sure the source and destination paths exist.
11[stderr] [07:57:36] Error: [android.dangerous]: withAndroidDangerousBaseMod: Cannot copy google-services.json from /build/workingdir/build/google_services_base64 to /build/workingdir/build/android/app/google-services.json. Please make sure the source and destination paths exist.
12[stderr] at setGoogleServicesFile (/build/node_modules/@expo/config-plugins/src/android/GoogleServices.ts:79:11)
13[stderr] at processTicksAndRejections (internal/process/task_queues.js:93:5)
14[stderr] at /build/node_modules/@expo/config-plugins/src/android/GoogleServices.ts:53:7
15[stderr] at action (/build/node_modules/@expo/config-plugins/src/plugins/withMod.ts:227:23)
16[stderr] at interceptingMod (/build/node_modules/@expo/config-plugins/src/plugins/withMod.ts:108:21)
17[stderr] at interceptingMod (/build/node_modules/@expo/config-plugins/src/plugins/withMod.ts:108:21)
18[stderr] at interceptingMod (/build/node_modules/@expo/config-plugins/src/plugins/withMod.ts:108:21)
19[stderr] at action (/build/node_modules/@expo/config-plugins/src/plugins/createBaseMod.ts:82:21)
20[stderr] at interceptingMod (/build/node_modules/@expo/config-plugins/src/plugins/withMod.ts:108:21)
21[stderr] at evalModsAsync (/build/node_modules/@expo/config-plugins/src/plugins/mod-compiler.ts:172:25)
22[stderr] at compileModsAsync (/build/node_modules/@expo/config-plugins/src/plugins/mod-compiler.ts:82:10)
23[stderr] at configureManagedProjectAsync (/build/node_modules/expo-cli/src/commands/eject/configureProjectAsync.ts:64:12)
24[stderr] at prebuildAsync (/build/node_modules/expo-cli/src/commands/eject/prebuildAsync.ts:90:21)
25[stderr] at actionAsync (/build/node_modules/expo-cli/src/commands/prebuildAsync.ts:37:3)
node exited with non-zero code: 1

you are restoring secret to google-services.json in the preinstall hook, but in your app.json you have google_services_base64 specified

These might be dumb questions but this is totally new are to me so here I go.
What value should I add to expo.android.googleServicesFile?
I have tried:

"googleServicesFile": "google-services",
"googleServicesFile": "google-services.json",
"googleServicesFile": "./google-services.json",

Where is the restored google-services.json located at?

if you have

"eas-build-pre-install": "echo $google_services_base64 | base64 -d > google-service.json"

then google-service.json will be in the same directory as eas.json
both second and third option should work

correction you have typo in the name

it can be either of those

"googleServicesFile": "google-service.json",
"googleServicesFile": "./google-service.json",

or change name in the eas-build-pre-install hook

You are absolutely correct. Thank you for your help and pointing out the mistake.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.