Build failed with an exception

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:compileDebugJavaWithJavac’.

error: invalid source release: 17

That error is thrown from within a Java environment.

As you have not documented your wider configuration I can not say exactly what is causing the issue, but you need to look at the Java version deployed and the setting in any config files that specify which Java to use.

this is the problem iam facing

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac’.

SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project’s local properties file at ‘/home/circleci/code/local.properties’.

  • Try:

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.
Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to Command-Line Interface in the Gradle documentation.

BUILD FAILED in 7s

Exited with code exit status 1

Exited with code exit status 1

Without any details regarding the CircleCI environment you are working in I can not provide any detailed feedback.

The key parts of that error message are

SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project’s local properties file at ‘/home/circleci/code/local.properties’.

and

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

These are both Java environmental errors, rather than CircleCI errors.

this is the config file.
version: 2
orbs:
android: circleci/android@1.0

jobs:
build:
working_directory: ~/code
docker:
- image: cimg/openjdk:17.0.2
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- run:
name: Chmod permissions
command: chmod +x ./gradlew

  - run:
      name: Check Java Installation
      command: java -version

  - run:
      name: Download Dependencies
      command: ./gradlew androidDependencies

  - save_cache:
      paths:
        - ~/.gradle
      key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}

  - run:
      name: List APK Directory
      command: ls -l

  - run:
      name: Assemble Debug
      command: ./gradlew --stacktrace assembleDebug

  - store_artifacts:
      path: app/build/outputs/apk/debug
      destination: artifact-files

OK that helps.

Your config.yml is specifies cimg/openjdk:17.0.2 which is a rather old image from January 2022, which contains gradle 7.3.2.

While it is not part of the script you have shared to start seeing Gradle 9.0 errors you must have a step that has caused an upgrade from 7.3.2 to 9.0. Unless you have also made changes to your gradle config files to support such an upgrade you will get the errors you are seeing.

You may also find that upgrading to Gradle 9.0 is a step to far, even the latest images from CircleCI are only using gradle 8.1.

Sorry for troubling you, Can you please check my config file, for every alternative build i am getting different issue, if am resolving one issue its targeting to next one, iam using java 17 in my system, but still its showing as iam using java 11, i dont know where iam doing wrong.

Thank you!


The Java 11 is coming from your choice of docker image as the image circleci/android:api-30 is about 2 years old and includes Java 11. It is also considered a legacy image (see below).

The version of Gradle you are trying to use seems to be coming from the restore-cache command that is loading it from the CircleCI cache. From the code you have posted, it seems that this cached copy of gradlew is created as a later step. There is no indication of how the gradlew directory is created originally.

The image can be upgraded if you look at the following pages as the latest images include Java 17

You may need to sit down and fully document this process so that you can get a better understanding of what it is doing within your development cycle. One key issue is that it seems to create the cached copy of gradlew that it depends on, so if that cached copy is ever lost the script will stop running.

@rit1010 Thank you very much for your long support, it was working now, you kept an end for my long struggle.