Closed
Labels
bugSomething isn't working
Description
Description:
./gradlew build is 'Compiling and testing with Java 21' after actions/setup-java@v4 is setting Java 17.
I tried a lot of things:
- Zulu and Temurin
- manually downloading JDK 17 in one of the steps of the script
- task versions v3 and v4
- workaround with update-alternatives
- more info in GitHub support ticket for whoever can open it
Task version:
v3 and v4
Platform:
- Ubuntu
- macOS
- Windows
Runner type:
- Hosted
- Self-hosted
Repro steps:
Use this ci.yml in your Android project:
name: CI
on:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
# - name: Cache Gradle packages
# uses: actions/cache@v4
# with:
# path: |
# ~/.gradle/caches
# ~/.gradle/wrapper/
# key: ${{ runner.os }}-gradle-v1-${{ hashFiles('**/build.gradle', '**/build.gradle.kts', '**/settings.gradle', '**/settings.gradle.kts', '**/gradle.lockfile') }}
# restore-keys: |
# ${{ runner.os }}-gradle-v1-
- name: Grant execute permission for Gradle Wrapper
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Run Unit Tests
run: ./gradlew test
- name: Notify Success
if: success()
run: echo "Build and tests passed!"
- name: Notify Failure
if: failure()
run: echo "Build or tests failed!"
Note: I commented out the cache for the purpose of making sure that I'm not reusing gradle files
Expected behavior:
Build with Gradle step should show:
Compiling and testing with Java 17
Actual behavior:
Build with Gradle step shows:
Compiling and testing with Java 21
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
mahalakshmi-rekadi commentedon Dec 23, 2024
Hello @GabeGiro,
Thank you for reporting this issue. We will investigate it and get back to you as soon as we have some feedback.
v-gowridurgad commentedon Dec 30, 2024
Hi @GabeGiro, After replicating the issue using the provided workflow, we found that everything is working as expected. The Build with Gradle step is correctly compiling and testing with Java 17. For your reference, we’ve included link of the successful run. To assist us in further investigating, could you please share a link to the build or a public repository where the issue can be reproduced?
v-gowridurgad commentedon Jan 10, 2025
Hi @GabeGiro, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.
GabeGiro commentedon Jan 15, 2025
@gowridurgad I'm not going to work on this issue for at least 3 more weeks. Although I saw your successful build I'm curious what is the difference between our gradle files. I'm working with a mature Android project (few years) so there is 100% chance something is different and unfortunately Android builds don't have containerisation - hence it works on yours but not on mine.
Again, I will not work on this any time soon but if you can share your process in the meantime, that would be useful. Did you start you Android project from scratch, did you use Android Studio's empty project, are you using old or new gradle files?
And I will write all these for my project in few weeks.
Thank you in advance
v-gowridurgad commentedon Jan 20, 2025
Hi @GabeGiro, Android Gradle files include Android-specific plugin configurations, dependencies, and build configurations, while normal Gradle files are typically used for Java or other JVM-based projects without Android-specific configurations. we are using simple application using new Gradle files specific to our setup. To generate Gradle files:
For more detailed steps, refer to the official documentation on Building and testing Java with Gradle.
v-gowridurgad commentedon Jan 27, 2025
Hi @GabeGiro, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.
v-gowridurgad commentedon Feb 3, 2025
Hi @GabeGiro, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.
GabeGiro commentedon Feb 4, 2025
@gowridurgad thank you for sharing the link but it's not useful here. We are talking about Android-specific project. As mentioned before, I would appreciate if you shared some Android project files that enable you to build with Java 17.
Here is my setup:
.github/workflows/ci.yml:
Part of app's build.gradle:
Please, let me know if I can share anything else that will help you solve this.
v-gowridurgad commentedon Feb 10, 2025
Hi @GabeGiro, Thank you for providing detailed information about your setup. We tested this workflow with an Android project, specifically using Android Input Samples, and it worked correctly with Java 17. For reference, we have attached a screenshot of the successful build showing that the Gradle step is compiling and testing with Java 17.
Here are some troubleshooting steps that might help resolve your issue:
1. Verify Gradle Wrapper Version: Ensure that the Gradle wrapper version in your project supports Java 17. Update it to the latest compatible version if necessary by running:
./gradlew wrapper --gradle-version <latest-supported-version>2. Clean Gradle Cache: Since Gradle caching can sometimes cause unexpected issues, try clearing the cache before running the build:
./gradlew clean3. Set JAVA_HOME: Confirm that the JAVA_HOME variable points to JDK 17. Add a step to verify with:
4. Update Android Gradle Plugin: Verify that your Android Gradle plugin version is compatible with Java 17. You might need to update the plugin in your build.gradle file:
classpath "com.android.tools.build:gradle:<latest-compatible-version>"If the issue persists, consider replicating it in a smaller, newly created Android project to help narrow down the cause. Let us know if these steps resolve the problem or if there's anything else we can assist you with.
v-gowridurgad commentedon Feb 21, 2025
Hi @GabeGiro, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.
v-gowridurgad commentedon Feb 28, 2025
Hi @GabeGiro, Just a gentle reminder regarding this issue, If you have any updates or need further assistance, Please let us know.
v-gowridurgad commentedon Mar 10, 2025
Hi @GabeGiro, Due to inactivity, I'm going to close this issue for now. Please feel free to reopen this issue or create a new one if necessary. Thank you.