You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

本地Android EAS Build报Malformed root json错误,解码配置后仍失败

问题:EAS本地构建Android时processReleaseGoogleServices任务失败(Malformed root json)

执行eas build -p android --local命令进行本地构建时,触发以下错误:

Execution failed for task ':app:processReleaseGoogleServices'. > Malformed root json

已通过echo $GOOGLE_SERVICES_ANDROID_BASE64 | base64 --decode > ./google-services.json命令生成了google-services.json文件,但构建仍失败。注意:该项目并非Firebase项目。

已按照EAS文档将eas.json中的GOOGLE_SERVICES_FILE设置为dummy值以抑制文件未提交警告,但错误依旧存在。

参考配置文件

eas.json

{
  "cli": {
    "version": ">= 5.0.2",
    "appVersionSource": "remote"
  },
  "build": {
    "development": {
      "node": "18.12.1",
      "developmentClient": true,
      "distribution": "internal",
      "channel": "development",
      "env": {
        "APP_VARIANT": "development",
        "GOOGLE_SERVICES_FILE": "dummy"
      }
    },
    "preview": {
      "distribution": "internal",
      "channel": "preview",
      "env": {
        "GOOGLE_SERVICES_FILE": "dummy"
      }
    },
    "production": {
      "node": "18.12.1",
      "autoIncrement": true,
      "channel": "production",
      "env": {
        "GOOGLE_SERVICES_FILE": "dummy"
      }
    }
  },
  "submit": {
    "production": {
      "android": {
        "serviceAccountKeyPath": "../../local_key/a.json"
      }
    }
  }
}

app.config.js

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

export default {
  expo: {
    name: IS_DEV ? '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: 'a'
      }
    },
    owner: 'a',
    ios: {
      supportsTablet: true,
      bundleIdentifier: IS_DEV ? 'adev' : 'dev.a',
      config: {
        googleMapsApiKey: IS_DEV ? 'a'
      },
      associatedDomains: ['applinks:a.dev'],
      buildNumber: dayjs().format('YYYYMMDDHHmm')
    },
    android: {
      package: IS_DEV ? 'a.dev' : 'a.dev.a',
      googleServicesFile: './google-services.json',
      adaptiveIcon: {
        foregroundImage: './assets/splash.png',
        backgroundColor: '#ffffff'
      },
      config: {
        googleMaps: {
          apiKey: IS_DEV ? 'a'
        }
      },
      intentFilters: [
        {
          action: 'VIEW',
          autoVerify: true,
          data: [
            {
              scheme: 'https',
              host: 'a.dev',
              pathPrefix: '/a'
            }
          ],
          category: ['BROWSABLE', 'DEFAULT']
        }
      ]
    },
    web: {
      favicon: './assets/favicon.png'
    },
    plugins: [
      [
        '@stripe/stripe-react-native',
        {
          merchantIdentifier: '',
          enableGooglePay: false
        }
      ]
    ],
    updates: {
      url: 'https://u.expo.dev/1'
    },
    jsEngine: 'hermes'
  }
}

解决方案

因为项目并非Firebase项目,完全不需要google-services.json文件,错误根源是配置中强制指定了该文件,导致Gradle的Google Services插件尝试解析无效内容。按以下步骤修复:

  1. 移除app.config.js中的googleServicesFile配置:
    删除android字段下的googleServicesFile: './google-services.json'这一行。

  2. 清理eas.json中的冗余配置:
    删掉各个build环境(development/preview/production)下env中的GOOGLE_SERVICES_FILE: "dummy"项。

  3. 删除本地无效文件(可选):
    执行rm ./google-services.json删除生成的无效JSON文件。

  4. 重新执行构建:
    再次运行eas build -p android --local即可完成构建。

内容的提问来源于stack exchange,提问作者user42195

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 00:13:17