Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket pipeline fails for gradle 8.0 and JAVA 17

Pankaj Kumar April 28, 2023
Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
21
Your current JDK is located in /usr/lib/jvm/java-11-openjdk-amd64
Bitbucket pipeline config file :
+image: amazoncorretto:17 // to build docker image with java 17
 pipelines:
   pull-requests:
     '**':
       - step:
           size: 2x
           name: Unit Tests
           image: androidsdk/android-31:latest
           script:
             - chmod +x gradlew
             - ./gradlew app:testCompanionDevDebugUnitTest fleetlib:testDevDebugUnitTest --no-daemon
           artifacts:
             - app/build/reports/tests/testCompanionDevDebugUnitTest/

3 answers

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 1, 2023

Hi @Pankaj Kumar and welcome to the community!

I can see in your bitbucket-pipelines.yml file that you define an image both at the top (image: amazoncorretto:17) and also on the step level (image: androidsdk/android-31:latest). When you specify an image in both places, then the image defined on the step level will be used, in this case, androidsdk/android-31:latest. This Docker image has Java 11.

You can see the version locally if you have Docker installed on your computer. You can run the command

docker run -it --entrypoint=/bin/bash androidsdk/android-31:latest

In the bash prompt of the container that starts, you can run the command

java --version

You can check this way the version of tools in any other Docker image, by replacing androidsdk/android-31:latest with a different Docker image.

I see that the image amazoncorretto:17 has indeed Java 17, so if you want to use this image instead, you will need to remove the Docker image definition (image: androidsdk/android-31:latest) from the step level.

Make sure that the image definition at the top doesn't have the + sign at the beginning and the part "// to build docker image with java 17" (you can add a comment with the symbol # instead of //)

Kind regards,
Theodora

Pankaj Kumar May 3, 2023

Thanks @Theodora Boudale  , for your response. This has been resolved now.

Like Theodora Boudale likes this
4 votes
scrollbart June 22, 2023

You can use: 

alvrme/alpine-android:android-34-jdk17
Ravi Pun July 3, 2023

This works perfect for me as we are targeting android 34 and using JDK 17 on our project.

Thank you 

Like # people like this
0 votes
JokerKK May 30, 2023

Hi @Pankaj Kumar 

How did you manage to resolve this issue? Did you find image that works? I tried to use amazoncorretto:17 image, but then I get error: 

-----
What went wrong: Could not determine the dependencies of the task ':app:testDebugUnitTest'. > SDK location not found. Please define a valid SDK location by setting the ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local.properties file located at '/opt/atlassian/pipelines/agent/build/local.properties'.
-----

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 31, 2023

Hi @JokerKK ,

The error message you see indicates that the build cannot find the Android SDK. It looks like the Android SDK is not pre-installed in amazoncorretto:17 image.

You will need to either use a different existing image that has the tools you need pre-installed or build your own custom image. We support public and private Docker images including those hosted on Docker Hub, AWS, GCP, Azure, and self-hosted registries accessible on the internet.

Another option would be to install the Android SDK during the build.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events