Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expo prebuild]: Error: [android.dangerous]: withAndroidDangerousBaseMod: Path to google-services.json is not defined. Please specify the expo.android.googleServicesFile field in app.json. #2141

Closed
ilyagru opened this issue Dec 4, 2023 · 7 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@ilyagru
Copy link

ilyagru commented Dec 4, 2023

Build/Submit details page URL

No response

Summary

My project is managed and the ios/android folders are added to .gitignore. I'm trying to use Firebase and set up the project the way that it picks up google-services files from the root if it's running locally (the files are gitignored); and use Secret files on EAS if building on CI. It works locally but on EAS expo prebuild fails within the command eas build --platform all --non-interactive --profile production --auto-submit with the following error:

Error: [android.dangerous]: withAndroidDangerousBaseMod: Path to google-services.json is not defined. Please specify the `expo.android.googleServicesFile` field in app.json

My app.config.js is:

module.exports = {
  /** @type {import('expo/config').ExpoConfig} */
  expo: {
    owner: '...',
    name: '...',
    slug: '...',
    version: '1.1.0',
    orientation: 'portrait',
    icon: './assets/images/icon.png',
    userInterfaceStyle: 'light',
    platforms: ['ios', 'android'],
    splash: {
      image: './assets/images/splash.png',
      resizeMode: 'contain',
      backgroundColor: '#ffffff'
    },
    assetBundlePatterns: ['assets/images/*', 'assets/icons/*', 'assets/fonts/*'],
    ios: {
      bundleIdentifier: '...',
      supportsTablet: true,
      infoPlist: {
        ITSAppUsesNonExemptEncryption: false,
        UIDeviceFamily: [1, 2]
      },
      usesAppleSignIn: true,
      googleServicesFile: process.env.GOOGLE_SERVICES_FILE_IOS
    },
    android: {
      package: '...',
      adaptiveIcon: {
        foregroundImage: './assets/images/adaptive-icon.png',
        backgroundColor: '#7D6AF3'
      },
      googleServicesFile: process.env.GOOGLE_SERVICES_FILE_ANDROID
    },
    plugins: [
      ['./plugins/withAndroidQueries.plugin.js'],
      ['expo-build-properties', { ios: { useFrameworks: 'static' } }],
      ['@react-native-firebase/app'],
      ['@react-native-google-signin/google-signin'],
      // Used only to set iOS Sign-In capability on prebuilding.
      ['expo-apple-authentication']
    ],
    extra: {
      eas: {
        projectId: '...'
      }
    },
    experiments: {
      tsconfigPaths: true
    }
  }
}

.env.local

GOOGLE_SERVICES_FILE_IOS=./GoogleService-Info.plist
GOOGLE_SERVICES_FILE_ANDROID=./google-services.json

EAS Build logs - Spin up build environment

Environment secrets:
  GOOGLE_SERVICES_FILE_ANDROID=/home/expo/workingdir/environment-secrets/8695f37-3442-4da5-afdd-546de94b93
  GOOGLE_SERVICES_FILE_IOS=/home/expo/workingdir/environment-secrets/c6fd555-48a7-4f7-a159-fdafef74e66

EAS Build logs - read app config

So the variables are expanded correctly

"ios": {
    ...
    "googleServicesFile": "/home/expo/workingdir/environment-secrets/c6fd555-48a7-4f7-a159-fdafef74e66"
  },
  "android": {
    ...
    "googleServicesFile": "/home/expo/workingdir/environment-secrets/8695f37-3442-4da5-afdd-546de94b93"
  },

Since everything is defined, I don't expect the error. And since it is defined in the app.config.js, why does it look at the non-existent app.json?

Kind regards

Managed or bare?

Managed

Environment

expo-env-info (it seems like Expo Workflow: bare is incorrect, although the project is managed):

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 14.1.1
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.18.2 - /opt/homebrew/opt/node@18/bin/node
      Yarn: 1.22.19 - /opt/homebrew/bin/yarn
      npm: 9.8.1 - /opt/homebrew/opt/node@18/bin/npm
      Watchman: 2023.10.30.00 - /opt/homebrew/bin/watchman
    Managers:
      CocoaPods: 1.14.2 - /Users/user/.rbenv/shims/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    IDEs:
      Android Studio: 2022.3 AI-223.8836.35.2231.10811636
      Xcode: 15.0.1/15A507 - /usr/bin/xcodebuild
    npmPackages:
      expo: ~49.0.18 => 49.0.18 
      react: 18.2.0 => 18.2.0 
      react-native: 0.72.6 => 0.72.6 
    npmGlobalPackages:
      eas-cli: 5.9.1
    Expo Workflow: bare

expo-doctor:

✔ Check Expo config for common issues
✔ Check package.json for common issues
✔ Check dependencies for packages that should not be installed directly
✔ Check for common project setup issues
✔ Check npm/ yarn versions
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check that packages match versions required by installed Expo SDK
✔ Check for legacy global CLI installed locally
✔ Check that native modules do not use incompatible support packages
✔ Check that native modules use compatible support package versions for installed Expo SDK

Didn't find any issues with the project!

Error output

Error: [android.dangerous]: withAndroidDangerousBaseMod: Path to google-services.json is not defined. Please specify the expo.android.googleServicesFile field in app.json

Reproducible demo or steps to reproduce from a blank project

  1. A project with managed workflow.
  2. Integrate Firebase.
  3. Add configuration similar as above.
  4. Build on EAS.
@ilyagru ilyagru added the needs review Issue is ready to be reviewed by a maintainer label Dec 4, 2023
@szdziedzic
Copy link
Member

Can you send me a link to your build?

@szdziedzic
Copy link
Member

Can you try to do

your_package_manage install
npx expo config --type public

in the pre-install hook and check what's the output.

@ilyagru
Copy link
Author

ilyagru commented Dec 14, 2023

TLDR; rename .env into .env.example and use gitignored .env.local instead.

Hey! It was confusing to figure that out but It's resolved now! I just renamed the .env file name from .env to .env.example. This file is used for env defaults and is committed into the repo. Locally, .env.local is used which is gitignored. This way, when the code is uploaded, EAS doesn't see the .env file and correctly picks up the Secrets env variables.

@ilyagru ilyagru closed this as completed Dec 14, 2023
@piclez
Copy link

piclez commented Jan 30, 2024

Just curious @ilyagru do you have google-services.json or GoogleService-Info.plist in your .gitignore as well?

@ilyagru
Copy link
Author

ilyagru commented Jan 31, 2024

Yes @piclez

@noobling
Copy link

For whatever cooked reason you can't use relative path i.e. ./... while building so you need the full path /<full-path-to-file>/...

@sushantdsuwal
Copy link

For whatever cooked reason you can't use relative path i.e. ./... while building so you need the full path /<full-path-to-file>/...

@noobling Thanks, this resolves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

5 participants