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

Android EAS build failing on Github Actions #1935

Closed
alessandrocapra opened this issue Jul 18, 2023 · 13 comments
Closed

Android EAS build failing on Github Actions #1935

alessandrocapra opened this issue Jul 18, 2023 · 13 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@alessandrocapra
Copy link

Build/Submit details page URL

https://expo.dev/accounts/quantoz/projects/qbs-test-app/builds/6708f5ba-dec0-4b4d-b474-440039bedffc#run-gradlew

Summary

Notes

Building locally with the same setup works

Expected

With the provided Github actions YML file below, a build should be created for both Android and iOS and the submission should take place thanks to the --auto-submit flag.


name: Build apps through Expo EAS 

on:
  pull_request:
    branches:
      - main

jobs:
  run-script:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write

    steps:
      - name: Check for EXPO_TOKEN
        run: |
          if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
            echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
            exit 1
          fi      
      - name: Check for GOOGLE_SERVICES_JSON
        run: |
          if [ -z "${GOOGLE_SERVICES_JSON}" ]; then
            echo "You must provide a GOOGLE_SERVICES_JSON environment variable for this job. This should be a secret linked to this project's Google service account in this repo's secrets."
            exit 1
          fi
        env:
          GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
      
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Google Service Account
        run: |
          echo '${{ secrets.GOOGLE_SERVICES_JSON }}' > ./mobile/google-service-account.json

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18.x
          cache: npm
          cache-dependency-path: mobile/package-lock.json

      - name: Setup Expo and EAS
        uses: expo/expo-github-action@v8
        with:
          eas-version: latest
          token: ${{ secrets.EXPO_TOKEN }}

      - name: Install dependencies
        run: |
          cd mobile
          npm install

      - name: Run script
        run: |
          cd mobile
          eas build --profile preview-store --platform all --non-interactive --auto-submit

Actual behavior

iOS works perfectly, but the Android build fails with the error output below.

Managed or bare?

Managed

Environment

expo-env-info 1.0.5 environment info:
System:
OS: macOS 13.1
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
Yarn: 1.22.15 - ~/.nvm/versions/node/v16.15.0/bin/yarn
npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
Watchman: 2023.04.17.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.12.1 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.3/14E222b - /usr/bin/xcodebuild
npmPackages:
expo: ~48.0.18 => 48.0.20
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.71.8 => 0.71.8
npmGlobalPackages:
eas-cli: 3.15.1
expo-cli: 6.3.9
Expo Workflow: managed

Expo doctor:
Check package.json for common issues
✔ Validate global prerequisites versions
✔ Validate Expo Config
✔ Check for conflicting global packages in project
✔ Check for incompatible packages
✔ Verify prebuild support package versions are compatible
✔ Check compatible dependency versions for the installed Expo SDK

Didn't find any issues with the project!

Error output

Parsing json file: /home/expo/workingdir/build/mobile/android/app/google-services.json

> Task :expo-dev-launcher:generateReleaseAssets UP-TO-DATE

> Task :expo-constants:createReleaseExpoConfig

> Task :expo-dev-launcher:packageReleaseAssets

[stderr] 
FAILURE: Build completed with 2 failures.

[stderr] 
1: Task failed with an exception.

[stderr] 
-----------

[stderr] 
* What went wrong:

[stderr] 
Execution failed for task ':app:processReleaseGoogleServices'.

[stderr] 
> Missing project_info object

[stderr] 
* Try:

[stderr] 
> Run with --stacktrace option to get the stack trace.

[stderr] 
> Run with --info or --debug option to get more log output.

[stderr] 
> Run with --scan to get full insights.

[stderr] 
==============================================================================

[stderr] 
2: Task failed with an exception.

[stderr] 
-----------

[stderr] 
* What went wrong:

[stderr] 
java.lang.StackOverflowError (no error message)

[stderr] 
* Try:

[stderr] 
> Run with --stacktrace option to get the stack trace.

[stderr] 
> Run with --info or --debug option to get more log output.

[stderr] 
> Run with --scan to get full insights.

[stderr] 
==============================================================================

[stderr] 
* Get more help at https://help.gradle.org

[stderr] 
BUILD FAILED in 3m 49s

Reproducible demo or steps to reproduce from a blank project

I think it might be something simple I am missing or that I could not find in the docs, if that's not the case I will try to create a new app and create the app on the google play console.

@alessandrocapra alessandrocapra added the needs review Issue is ready to be reviewed by a maintainer label Jul 18, 2023
@szdziedzic
Copy link
Member

Hi,

I googled it and it seems like an issue connected with a missing google-services.json file.

Do you have push notifications set up for your project?

@alessandrocapra
Copy link
Author

Thanks for the reply! Nope, no push notifications set up, I though EAS automatically takes the google-service-account.json file and transforms it into that one for the Android build process.
I do not have such file that I manage myself, I am merely using the file I mentioned above to handle the submission through EAS Submit.

@alessandrocapra
Copy link
Author

As additional info, I tried the following:

  • setup a secret both on Github and Expo project, to store the contents of the JSON file (I have removed all unnecessary characters, like spaces and newlines)
  • tried to encode the file contents in base64 and save that as secrets, then using the eas-build-pre-install hook to decode it back into the google-service-account.json file

@szdziedzic
Copy link
Member

szdziedzic commented Jul 18, 2023

Thanks for the reply! Nope, no push notifications set up, I though EAS automatically takes the google-service-account.json file and transforms it into that one for the Android build process.

So the EAS Build manages the Android build credentials needed for signing your build https://docs.expo.dev/app-signing/app-credentials/

The google-services.json file is something different. These credentials are needed for enabling Google APIs or Firebase services and are not managed by EAS. It seems like you aren't providing the google-services.json file as a google-services.json file, but some other service account credentials file (google-service-account.json).

The contents of google-services.json should look like

{
  "project_info": {...},
  "client": [...],
}

https://developers.google.com/android/guides/google-services-plugin#processing_the_json_file

Could you let me know if the file you provided has this structure?

Or more like

{
  "type": "service_account",
  "project_id": "PROJECT_ID",
  "private_key_id": "KEY_ID",
  "private_key": "-----BEGIN PRIVATE KEY-----\nPRIVATE_KEY\n-----END PRIVATE KEY-----\n",
  "client_email": "SERVICE_ACCOUNT_EMAIL",
  "client_id": "CLIENT_ID",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://accounts.google.com/o/oauth2/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/SERVICE_ACCOUNT_EMAIL"
}

(which is the service account json structure)?

@alessandrocapra
Copy link
Author

Oh wait, I have a doubt now: it's the first time I use --non-interactive, does that respond yes to setting up push notifications? Because I usually always reply no, but manually.

@szdziedzic
Copy link
Member

This question is asked only for iOS

@szdziedzic
Copy link
Member

szdziedzic commented Jul 18, 2023

Do you use Firebase in your app?

@alessandrocapra
Copy link
Author

Nope, not really. Maybe it's faster this way, is there a proven way to submit automatically when merging on main? I went through the docs and found some scattered instructions, including the Github Actions example, but it does not cover the example of submitting as well

@szdziedzic
Copy link
Member

szdziedzic commented Jul 18, 2023

Nope, not really. Maybe it's faster this way, is there a proven way to submit automatically when merging on main? I went through the docs and found some scattered instructions, including the Github Actions example, but it does not cover the example of submitting as well

So basically using the --auto-submit option (which you are already using) should do the job if your build succeeds. If your build fails the submission is canceled, because the --auto-submit option corresponds to the build you just started using the same command.

@alessandrocapra
Copy link
Author

You're completely right, it's build-related and that needs to be solved first. I am unsure though, until some days ago simply using eas build would work perfectly.

This error I am getting now is unexpected since I do not even have the android and ios folders locally (using the managed workflow). So I obviously never created the other JSON file that is throwing the error, I just assumed it's the EAS build failing because of internal reasons

@szdziedzic
Copy link
Member

Did you add some new external dependencies between your last successful build and now?

@alessandrocapra
Copy link
Author

Sorry, had other prios to work on. Back to this, I have only added some scripts for Github Actions, which should not be the cause for the failing build correct?

Is there any command I could run to get more debug info on why is a google.services.json expected, since I am in the managed workflow and I do not even have android/ios folder in my project?

Thanks for your help!

@alessandrocapra
Copy link
Author

Silly me, I got confused by the guide in the environment variables section regarding EAS build, where they mentioned a google services file. I assumed it was the one I needed (google-service-account.json), but it's referring indeed to Firebase.

Sorry and thanks for helping out, I managed to save the contents of the Google Service Account file encoded as base64 in my Github repo secrets and in the CI step I am decoding it and writing it in the file. If there is a better way to do this, feel free to add a comment but it seems to work.

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

2 participants