EAS build fails on Android only (Malformed root json)

Hello,

My EAS build is working on iOS but failing on Android with the following message:

...
[stderr] Execution failed for task ':app:processReleaseGoogleServices'.
[stderr] > Malformed root json
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
...

I think it’s related to the google-services.json file.

This is what I did:

  1. I created a secret on expo and inserted the values of my google-services.json file.
  2. I created a pre install script on the package json:
"eas-build-pre-install": "echo $GOOGLE_SERVICES_JSON > google-services.json && echo $GOOGLE_SERVICES_INFO_PLIST > GoogleService-Info.plist"

I am not sure what’s wrong. I also don’t know how to run with --debug option to get more information.

My project is managed and i’m using Expo SDK V41

You can test more by running your build locally. The most likely issue here is your custom script isn’t writing the google services correctly

To run the test locally I changed the script to the following:

"eas-build-pre-install": "echo \"$(<firebase-envs/prod/google-services.json)\" > google-services.json"

And I had no errors during app:processReleaseGoogleServices.

However I did get another error which I also don’t know how to solve:

Execution failed for task ':app:processReleaseMainManifest'.
[RUN_GRADLEW] > Manifest merger failed : Attribute data@scheme at AndroidManifest.xml requires a placeholder substitution but no value for <appAuthRedirectScheme> is provided.

Is my original eas-build-pre-install script wrong and I am not extracting the value?

I think you might need to quote the environment variables, like:

"eas-build-pre-install": "echo \"$GOOGLE_SERVICES_JSON\" > google-services.json && echo \"$GOOGLE_SERVICES_INFO_PLIST\" > GoogleService-Info.plist"

Manifest merger failed : Attribute data@scheme at AndroidManifest.xml requires a placeholder substitution but no value for is provided.

my guess is you’re using expo-app-auth but the confiug plugin that sets appAuthRedirectScheme isn’t working correctly. It should default to your scheme though

1 Like

I changed to what you propose and I am still getting the same error

I don’t have expo-app-auth but I do have expo-google-app-auth which is a wrapper. I added the scheme to my app.json but I still have the same error when I try to build localy.

This are my package.json dependencies:

"dependencies": {
    "@apollo/react-hooks": "^3.1.5",
    "@burstware/expo-plaid-link": "^1.0.1",
    "@expo/metro-config": "^0.1.80",
    "@expo/vector-icons": "^12.0.0",
    "@optimizely/react-sdk": "^2.6.2",
    "@react-native-async-storage/async-storage": "^1.13.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "6.0.0",
    "@react-navigation/material-top-tabs": "^5.2.14",
    "@react-navigation/native": "^5.4.0",
    "@react-navigation/stack": "^5.3.7",
    "@sentry/react-native": "^2.1.0",
    "@types/base-64": "^0.1.3",
    "@use-expo/font": "^2.0.0",
    "apollo-boost": "^0.4.9",
    "apollo-cache-inmemory": "^1.6.6",
    "apollo-client": "^2.6.10",
    "apollo-link-context": "^1.0.20",
    "apollo-link-http": "^1.5.17",
    "base-64": "^0.1.0",
    "buffer": "^5.6.0",
    "expo": "^41.0.0",
    "expo-analytics-amplitude": "~10.1.0",
    "expo-app-loading": "^1.1.2",
    "expo-apple-authentication": "~3.1.0",
    "expo-application": "~3.1.2",
    "expo-blur": "~9.0.3",
    "expo-constants": "~10.1.3",
    "expo-crypto": "~9.1.0",
    "expo-device": "~3.2.0",
    "expo-facebook": "~11.0.5",
    "expo-firebase-analytics": "~4.0.2",
    "expo-font": "~9.1.0",
    "expo-google-app-auth": "^8.1.3",
    "expo-haptics": "~10.0.0",
    "expo-linear-gradient": "~9.1.0",
    "expo-local-authentication": "~11.0.2",
    "expo-notifications": "~0.11.6",
    "expo-updates": "~0.5.4",
    "expo-web-browser": "~9.1.0",
    "firebase": "8.2.3",
    "graphql": "^15.1.0",
    "lodash": "^4.17.21",
    "moment": "^2.27.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
    "react-native-base64": "^0.2.1",
    "react-native-crypto-js": "^1.0.0",
    "react-native-dialog": "^6.1.2",
    "react-native-flash-message": "^0.1.23",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-modal": "^11.10.0",
    "react-native-pager-view": "5.0.12",
    "react-native-phone-number-input": "^1.1.0",
    "react-native-reanimated": "~2.1.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.0.0",
    "react-native-skeleton-placeholder": "^3.0.2",
    "react-native-smooth-pincode-input": "^1.0.9",
    "react-native-status-bar-height": "^2.6.0",
    "react-native-svg": "12.1.0",
    "react-native-svg-transformer": "^0.14.3",
    "react-native-swipe-gestures": "^1.0.5",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^2.15.0",
    "react-native-uuid": "^2.0.1",
    "react-native-virtual-keyboard": "^1.1.0",
    "react-native-web": "~0.13.12",
    "react-native-webview": "11.2.3",
    "react-native-youtube-iframe": "^1.2.4",
    "react-number-format": "^4.4.1",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "sentry-expo": "^3.1.0",
    "validator": "^13.6.0"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "@types/react": "~16.9.35",
    "@types/react-native": "~0.63.2",
    "@types/react-native-base64": "^0.1.0",
    "@types/react-native-uuid": "^1.4.0",
    "@types/react-redux": "^7.1.8",
    "@typescript-eslint/eslint-plugin": "^4.8.1",
    "@typescript-eslint/parser": "^4.8.1",
    "babel-plugin-module-resolver": "^4.0.0",
    "babel-preset-expo": "8.3.0",
    "eslint": "^7.14.0",
    "eslint-config-universe": "^6.0.0",
    "eslint-import-resolver-typescript": "^2.3.0",
    "husky": "^4.2.5",
    "lint-staged": "^10.2.11",
    "prettier": "^2.2.0",
    "typescript": "~4.0.0"
  },

I migrated expo-google-app-auth to expo-auth-session/providers/google and now the build is working locally.

However I am still getting:

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

When trying to build the app remotely.

I am sure the issue is in the eas-build-pre-install script but I don’t know what’s wrong.

the original pre-install script you provided looks correct:

"eas-build-pre-install": "echo $GOOGLE_SERVICES_JSON > google-services.json && echo $GOOGLE_SERVICES_INFO_PLIST > GoogleService-Info.plist"

I tried that one too but I get the same error :upside_down_face:

try printing the google-services.json contents also, to ensure that it’s being populated with what you expect. cat google-services.json

1 Like

Thanks @notbrent, I was able to notice that my google-services.json file was empty.

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