Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
Your current JDK is located in /usr/lib/jvm/java-11-openjdk-amd64
+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/
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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'.
-----
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.