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 project update to Gradle 8 and Java 17 build fails without reason. #7915

Closed
2 of 10 tasks
Canato opened this issue Jul 13, 2023 · 8 comments
Closed
2 of 10 tasks

Comments

@Canato
Copy link

Canato commented Jul 13, 2023

Description

I update my Android project to Gradle 8 and Java 17.
After that, my GitHub Actions stop to work for assemble gradle command.
(more after some context)

Context

Gradle

  • DistributionUrl https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip (before 7.5.1-bin)
  • Version 8.0.2 (before 7.4.0)

Java

  • JavaVersion.VERSION_17 (before JavaVersion.VERSION_11)

Fixed update issues

  • BuildConfig files disable
  • Fix resource imports (multi gradle module project)
  • Improve R8 proguard rules

Gradle properties added

  • org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

Github Actions Workflow

Gradle commands of each job

  • detektAllModules ✅ (custom detekt/lint gradle method)
  • testPhoneDebugUnitTest
  • :app:legacy:base:test :app:legacy:domain:test :app:legacy:data:test :app:data:socketio-client:test :app:data:mqtt-server:test :app:data:network-exceptions:test
  • bundlePhoneRelease 🚫
  • assemblePhoneDebug 🚫

Obs:

  1. Both commands work running locally on my machine
  2. Both commands work before the update
  3. Both commands work on the main branch (without the update)

Github Actions for assemblePhoneDebug

Was added Setup-java step for Java 17 compatibility (I believe the problem is close to this)

  build_phone_debug_job:
    env:
      CI: "true"
    name: Build Phone Debug
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - name: Checkout the code
        uses: actions/checkout@v3

      - name: Setup-java
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: '17'

      - name: Cache gradle files
        uses: actions/cache@v3
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
          restore-keys: |
            ${{ runner.os }}-gradle-

      - name: Build Phone Debug
        uses: gradle/gradle-build-action@v2.4.2
        with:
          arguments: assemblePhoneDebug

No error is shown, but after re-running enabling debug logging, we can see:

Node Action run completed with exit code 143

The build took 6m to fails, we have a timeout of 30min

Before re-running

After re-run with debug

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 11
  • macOS 12
  • macOS 13
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Not sure where "Set up job" -> "Runner Image" -> "Version" is.
But we are using the default GitHub runner's latest ubuntu version.

Is it regression?

No

Expected behavior

We should have a final build or a clear error message

Actual behavior

Fails without explanation

Repro steps

Android project with gradle 8, Java 17, using GitHub Actions with the latest Ubuntu should reproduce.

@Alexey-Ayupov
Copy link
Collaborator

Hello @Canato. We will take a look.

@sergei-pyshnoi
Copy link
Contributor

Hello @Canato . Is it possible to provide more detailed repro steps with code example? It can be workflow in your repo or create separate one if it private. Also, can you share link with passing and failing runs?

@Canato
Copy link
Author

Canato commented Jul 24, 2023

@sergei-pyshnoi will take me some days to return for you with it because is a busy week, but will do

@sergei-pyshnoi
Copy link
Contributor

Hello @Canato . Unfortunately, due missing additional information and repro steps, I have to close this tread. Please come back when you have more detailed information and I will reopen issue for you. If you have additional questions, feel free to ask.

@Onvistlex
Copy link

Onvistlex commented Aug 17, 2023

If androids R8 is enabled, it could be that ubuntu is running out of memory. In our case, this resulted in exit code 143. To fix this problem, you can increase the swapfile: https://stackoverflow.com/a/76921482/1185087


  - name: Increase swapfile
    run: |
      sudo swapoff -a
      sudo fallocate -l 15G /swapfile
      sudo chmod 600 /swapfile
      sudo mkswap /swapfile
      sudo swapon /swapfile
      sudo swapon --show

@psdewar
Copy link

psdewar commented Aug 31, 2023

Installing Java 11 fixed this for me

@GoudarziDeveloper
Copy link

Hello friends, I recently created a project with Gradle 8 and everything is fine until I make a release and activate R8, then the API stops working.
I have already configured proguard rules and this problem did not exist in griddle 7.4. Can anyone help me figure out the problem?

@Canato
Copy link
Author

Canato commented Dec 15, 2023

I'm so sorry for taking so long to return to this.
But I found the "real" issue.

Gradle takes too much memory and fails without a clear error log.
This is discussed here: ubuntu-latest: jobs fail with error code 143 where the ubuntu-latest does not have enough capacity to deal with Gradle sometimes, and this happened with me during my update.

Based on the thread/issue above, I changed my runner for a GitHub Large runner, and it worked perfectly; later, my team built a device farm locally running on a Mac, and everything ran smoothly. So it was (at least in my case) a runner memory/capacity issue.

@GoudarziDeveloper, I suggest you open another issue, but check your logs. R8 became more "aggressive" on this version, but it generates a file under the build folder with all the new rules you need to add to your guard files, literally copying and pasting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants