game-ci / unity-builder

Build Unity projects for different platforms
https://github.com/marketplace/actions/unity-builder
MIT License
846 stars 245 forks source link

JDK not found #489

Closed achimmihca closed 1 year ago

achimmihca commented 1 year ago

Bug description

I just upgraded to Unity 2022.2.1f1 and game-ci/unity-builder@v2.1.2 The build for most platforms works fine.

Only Android build has issues because the JDK is not found:

2023-01-09T11:27:13.6923522Z DisplayProgressbar: Detect Java Development Kit (JDK)
2023-01-09T11:27:13.9736423Z UnityException: JDK not found
2023-01-09T11:27:13.9737808Z Java Development Kit (JDK) directory is not set or invalid. Please, fix it in Edit / Unity -> Preferences -> External Tools
2023-01-09T11:27:13.9739136Z UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[], Boolean)
2023-01-09T11:27:13.9740684Z UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[]) (at /home/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:481)
2023-01-09T11:27:13.9742309Z UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[]) (at /home/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:359)
2023-01-09T11:27:13.9744078Z UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions) (at /home/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:323)
2023-01-09T11:27:13.9745377Z UnityBuilderAction.Builder:BuildProject() (at Assets/Editor/Editor/UnityBuilderAction/Builder.cs:71)

In Preferences -> External Tools the check box is set for JDK installed with Unity (recommended).

I see Docker Hub has some images with android in its name. Do I have to use a specific image?

Expected behavior

The Docker image should include the JDK at the expected location.

Additional details

Please find the GitHub Actions yml configuration here and the program output here

So far, I just specified

...
        unityVersion:
          - 2022.2.1f1
        targetPlatform:
          - Android # does NOT work at the moment
          - iOS     # does work
ErcinDedeoglu commented 1 year ago

This is unity's problem. Unluckily recent version has this bug. It's not setting the correct JDK to the editor on installation. I faced this error one week ago, and there is no easy workaround.

AndrewKahr commented 1 year ago

For reference, this was brought up on the GameCI Discord: https://discord.com/channels/710946343828455455/1053868095615283211

achimmihca commented 1 year ago

Seems to be fixed in Unity 2022.2.2f1

achimmihca commented 1 year ago

Sorry, was celebrating too early. The issue still occurrs in Unity 2022.2.2f1

achimmihca commented 1 year ago

Related post on Unity forums: https://forum.unity.com/threads/unity-hub-cli-does-not-install-android-jdk.1375761/#post-8670387

achimmihca commented 1 year ago

This forum post names a different cause: file permissions are not set properly. I guess this could be fixed easily on our side.

AndrewKahr commented 1 year ago

One of the discord members seems to have gotten Unity to fix the issue: https://discord.com/channels/710946343828455455/1053868095615283211/1065926313661181952

NordlightPer commented 1 year ago

Any news on this issue?

AndrewKahr commented 1 year ago

Still waiting on Unity to release an update unfortunately

CheeryLee commented 1 year ago

The solution is quite simple.

This problem is not entirely related to Unity. To be more concretical, this is the issue with outdated version of Unity Hub. You have to update it to the latest one (currently 3.4.1 will be the minimal compatible) to get a working installation of OpenJDK.

An output of OpenJDK version command that installed along with 2022.2.8 via Unity Hub 3.4.1:

alex@CLI6:~$ ~/Unity/Hub/Editor/2022.2.8f1/Editor/Data/PlaybackEngines/AndroidPlayer/OpenJDK/bin/java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

To get it to work with CI Docker images just change hubVersion argument https://github.com/game-ci/docker/blob/main/images/ubuntu/hub/Dockerfile and rebuild the hub image, after that rebuild the engine image.

UPD: just realized that the bug only persists while installing modules in headless mode. If you install OpenJDK using UI, the resulted modules.json layout will be different and it will contain the URL to JDK 11. Need to dig it deeper.

AndrewKahr commented 1 year ago

@CheeryLee Please see this thread here: https://discord.com/channels/710946343828455455/1053868095615283211

TLDR: Unity has fixed it internally, we are waiting for hub to release 3.5. There are also additional steps needed like fixing the errors thrown by new hub versions due to gpu acceleration and if Unity doesn't fix the sym link issue we need to bake the sym link fix into the images as well.

CheeryLee commented 1 year ago

@AndrewKahr unfortunately for unknown reason I have no access to this server. However, if the problem will be fixed in 3.5 then it's nice. I'll stay tuned. Thank you for the info.

patricsgamma commented 1 year ago

Just a side note, but there's an issue with the internal discord links you are sharing here.

So this seams to be a quite close circle discussion. Does someone know a workaround for the issue?

webbertakken commented 1 year ago

It's not a private discord or close circle in any way.

It's actually the community (public) home. You can use this invite until someone fixes the url: https://discord.gg/ZjpyhCRd

Edit: Issue is fixed in https://github.com/game-ci/documentation/pull/374

AndrewKahr commented 1 year ago

Weird that discord doesn't just give the option to join. I copied the link for the thread so it would link directly to the right message. Didn't know it wouldn't just let you join if you haven't already.

romas34 commented 1 month ago

I installed Unity 2022.1.24f1 by Unity Hub version 3.9.0. And got an error:

UnityException: JDK not found Java Development Kit (JDK) directory is not set or invalid. Please, fix it in Edit / Unity -> Preferences -> External Tools

At Preferences->External Tools i see error/warning: "You are missing the recommended JDK. Install the recommended version using Unity Hub."

And i can't build the project. How can this be fixed?