I’m encountering an issue during the build process of my Android project using AWS CodeBuild. The build fails with the following error:
[Container] 2024/08/07 06:53:09.877690 Running command echo Building the project
Building the project
[Container] 2024/08/07 06:53:09.883192 Running command ./gradlew :app:bundleRelease
Downloading https://services.gradle.org/distributions/gradle-7.3.3-bin.zip
………………………………………………………………………………………………..
Unzipping /root/.gradle/wrapper/dists/gradle-7.3.3-bin/6a41zxkdtcxs8rphpq6y0069z/gradle-7.3.3-bin.zip to /root/.gradle/wrapper/dists/gradle-7.3.3-bin/6a41zxkdtcxs8rphpq6y0069z
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-7.3.3-bin/6a41zxkdtcxs8rphpq6y0069z/gradle-7.3.3/bin/gradle
Welcome to Gradle 7.3.3!
Here are the highlights of this release:
- Easily declare new test suites in Java projects
- Support for Java 17
- Support for Scala 3
For more details see https://docs.gradle.org/7.3.3/release-notes.html
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
- What went wrong:
java.lang.UnsupportedClassVersionError: dagger/hilt/android/plugin/HiltGradlePlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
dagger/hilt/android/plugin/HiltGradlePlugin has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Context:
–> I am using AWS CodeBuild for my CI/CD pipeline.
–> The project uses Dagger Hilt for dependency injection.
the below is my buildspec.yml
version: 0.2
phases:
build:
commands:
– aws s3api get-object –bucket release-key.jks –key release-key.jks ./releaseKey.jks
– cp ./releaseKey.jks ${CODEBUILD_SRC_DIR}/app/releaseKey.jks
– echo Writing keyPassword
– echo $keyPassword
– export STORE_FILE=releaseKey.jks
– export KEY_ALIAS=$keyAlias
– export KEY_PASSWORD=$keyPassword
– export STORE_PASSWORD=$storePassword
– ./gradlew :app:bundleRelease
artifacts:
files:
– app/build/outputs/bundle/release/app-release.aab
How can I resolve the UnsupportedClassVersionError for dagger/hilt/android/plugin/HiltGradlePlugin?
What I have tried:
–> Verifying that the Gradle version used is compatible with Java 11.
—> Ensuring that the correct version of Java is being used during the build process.
but when I am installing JDK 11 then it is throwing some issues related to apt-get update
the error is
[Container] 2024/08/06 10:35:24.443386 Command did not exit successfully apt-get update exit status 100
[Container] 2024/08/06 10:35:24.446502 Phase complete: INSTALL State: FAILED
[Container] 2024/08/06 10:35:24.446521 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: apt-get update. Reason: exit status 100
i dont knwo how to solve this issue
Arbaz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.