Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: JAVA_HOME is set to an invalid directory: /opt/java/openjdk #11

Closed
dellisd opened this issue Jul 14, 2021 · 13 comments
Closed

ERROR: JAVA_HOME is set to an invalid directory: /opt/java/openjdk #11

dellisd opened this issue Jul 14, 2021 · 13 comments
Assignees
Labels

Comments

@dellisd
Copy link

dellisd commented Jul 14, 2021

The CI I have set up that uses this docker image suddenly stopped working and it appears to be related to the newest release.

This was using alvrme/alpine-android:android-30-jdk11:

Images used:
    build : docker.io/alvrme/alpine-android@sha256:c39202e4da263bb66bfc65a49bdba941f97bebc91c7ca9d48617fccb0b97acc8
+ ./gradlew ktlintCheck --no-parallel

ERROR: JAVA_HOME is set to an invalid directory: /opt/java/openjdk

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
@alvr
Copy link
Owner

alvr commented Jul 14, 2021

Hi @dellisd, I will take a look tomorrow. Meanwhile use the previous tag android-30-jdk11-v2021.06.09.

@alvr alvr added the bug label Jul 14, 2021
@alvr
Copy link
Owner

alvr commented Jul 15, 2021

Hi @dellisd, I was not able to reproduce it on my machine building skydoves/Pokedex.

image
building

It seems to be working using the latest version. Could you try again running the same command or another, like ./gradlew check or ./gradlew build. If the problem persists and the repo is public, post the link to the repo or upload a sample data with the same Gradle configuration otherwise.

This is also weird because the only change between versions is the Android 31 SDK.

@dellisd
Copy link
Author

dellisd commented Jul 15, 2021

Unfortunately the project isn't public so there isn't much I can share there, however I did run a build on a separate project that is open source, but the build worked normally.

Both the ktlintCheck and test commands failed with the same error.

Reverting to the previous tag did resolve the issue, so it does seem related to the latest image but I can't think of any reason why, especially as you say the only difference was the version of the SDK. This is running in a Bitbucket Pipeline, so perhaps that's related.

@nayaksushma
Copy link

Like @dellisd said, even my CI pipeline failed with the same error.
ERROR: JAVA_HOME is set to an invalid directory: /opt/java/openjdk

Reverting to previous tag resolved the issue.

@alvr
Copy link
Owner

alvr commented Jul 22, 2021

Hi @dellisd, @nayaksushma, @darekxan. Tomorrow I will create a test image using Liberica JDK instead of AdoptOpenJDK because of #10. I will let you know when it is ready so you can test this version.

@daviCalavera
Copy link

Hi, I have the same error using: alvrme/alpine-android:android-31 and alvrme/alpine-android:android-30
The strange thing is that if I use the image locally I have no problem, only through the CI.

@edwnmrtnz
Copy link

edwnmrtnz commented Jul 30, 2021

Hi, I have the same error using: alvrme/alpine-android:android-31 and alvrme/alpine-android:android-30
The strange thing is that if I use the image locally I have no problem, only through the CI.

That must be because you have a JAVA_HOME environment variable set to jdk11 already or you have configured your AS to use jdk11.

@alvr
Copy link
Owner

alvr commented Aug 1, 2021

I published a new version for AdoptOpenJDK alvrme/alpine-android:android-30-jdk11-v2021.08.01, aswell as one based on Liberica alvrme/alpine-android-liberica:android-30-jdk11-v2021.08.01. Please, try this two, and tell me if it works.

Thanks.

@dellisd
Copy link
Author

dellisd commented Aug 3, 2021

Gave the two new images a try today. The AdoptOpenJDK one failed with the same error, but the Liberica one ran normally.

@20100
Copy link

20100 commented Oct 18, 2021

So did you find why this message appears ?
ERROR: JAVA_HOME is set to an invalid directory: /opt/java/openjdk

It come from the Gradle wrapper which doesn't find java binary. But it appears only on CI, not on my local machine.
So If you have any news about this bug, warn me please.
Thanks

@20100
Copy link

20100 commented Oct 19, 2021

As a workaround, I set the JAVA_HOME to "". The Gradle wrapper does no more fails with the invalid directory : /opt/java/openjdk.
If it can help.

@alvr alvr self-assigned this Oct 22, 2021
@alvr
Copy link
Owner

alvr commented Oct 22, 2021

Hi @dellisd, @nayaksushma, @20100, @daviCalavera, @edwnmrtnz. The release v2021.10.22 now uses Liberica as base image. If the issues persists with this version, please, reopen the issue.

@alvr alvr closed this as completed Oct 22, 2021
@stefanoberdoerfer
Copy link

I'm still experiencing this issue with image: android-31-jdk11-v2022.01.01.
I wanted to upgrade from android-30-jdk11-v2021.05.05 (which is working) to android 31 and got this error message:
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/jdk-11.0.13-bellsoft-x86_64

After adding export JAVA_HOME="" to my CI-script (like @20100 mentioned) the error changed to a font error again which I experienced in the past. Eventhough I'm already manually installing fonts via apk add --no-cache freetype fontconfig ttf-dejavu (also mentioned here: usefulness/easylauncher-gradle-plugin#201).
Very strange.

Nevertheless I was able to get my build to work by using this older android-31 image: android-31-jdk11-v2021.08.01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants