Creating separate google-services.json files for Preview and Production environments in an Expo project and resolving eas build error

I am developing an application using Expo. The application is registered on the Google Play Console, and currently, I have two different environments, Preview and Production. I need to create separate google-services.json files and set them up correctly for each of these environments. Also I use react-native-map but not firebase stuff.

Is there a recommended way to create and manage different google-services.json files for Preview and Production environments? Also, I would appreciate guidance on how to utilize these files in my Expo project and how to set them up on the Google Play Console.

Additionally, when I run the command eas build -e preview -p android --local, I encounter the following error:

FAILURE: Build failed with an exception.
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] Execution failed for task ':app:processReleaseGoogleServices'.
[RUN_GRADLEW] > Malformed root json


import 'dotenv/config'
import dayjs from 'dayjs'
const IS_DEV = process.env.APP_VARIANT === 'development'
const IS_PREVIEW = process.env.APP_VARIANT === 'preview'

export default {
  expo: {
    name: IS_PREVIEW ? 'a Dev' : 'a',
    slug: 'a',
    scheme: 'a',
    version: '1.0.1',
    orientation: 'portrait',
    icon: './assets/splash.png',
    userInterfaceStyle: 'light',
    runtimeVersion: {
      policy: 'sdkVersion'
    splash: {
      image: './assets/splash.png',
      resizeMode: 'contain',
      backgroundColor: '#ffffff'
    assetBundlePatterns: [
    extra: {
      eas: {
        projectId: ''
    owner: 'a',
    ios: {
      supportsTablet: true,
      // jsEngine: 'jsc',
      bundleIdentifier: IS_PREVIEW ? '' : 'a',
      associatedDomains: [''],
      buildNumber: dayjs().format('YYYYMMDDHHmm')
    android: {
      package: IS_PREVIEW ? '' : 'a',
      // jsEngine: 'jsc',
      googleServicesFile: IS_PREVIEW ? './google-services-dev.json' : './google-services.json',
      adaptiveIcon: {
        foregroundImage: './assets/splash.png',
        backgroundColor: '#ffffff'
      config: {
        googleMaps: {
          apiKey: IS_PREVIEW ? 'a' : 'b'
      intentFilters: [
          action: 'VIEW',
          autoVerify: true,
          data: [
              scheme: 'https',
              host: '',
              pathPrefix: '/a'
          category: ['BROWSABLE', 'DEFAULT']
    web: {
      favicon: './assets/favicon.png'
    plugins: [
          merchantIdentifier: '',
          enableGooglePay: false
    updates: {
      url: 'https://a'
    jsEngine: 'hermes'

If there are any solutions or information related to this error, I would appreciate it if you could share that as well.

I also have a feeling that creating a new project on the Google Play Console might be the only way to resolve this issue, but I would like to know if there are any other methods.

Thank you for your assistance.

the approach you’re using there should work fine. it sounds like the json file that you’re providing is invalid though.

Thanks. So I should create a new google-service.json through Firebase console(new Android project) or Google Play console(new project)? I tried to make a new Android project through Firebase console. And I used it as google-service-dev.json. But it didn’t work.

did you get that same error message? can you use a json validator on your file?

Yeah. I get the same error. Of course, because I just made another Android project which is not related to my original expo app. When I don’t separate preview and production in app.config.js, the eas build was no error. So I think it’s not the matter of json validator or something. Just I want to know is how google-service.json is created. I don’t use firebase stuff in my project.

When I don’t separate preview and production in app.config.js, the eas build was no error

i suspect the file you are pointing to is missing or invalid. make sure it’s included in your build archive: - or if you are using another approach to include it, then verify the contents.

the file is copied to the native project using a very simple config plugin: