Skip to content

Republish android images to support all - how do we select the right SDK JDK NDK versions?

Alright, so here are some lights on the issues related to Android right now:

Android images (gableroux/unity3d:*-android) were recently rebuilt because some of them had wrong SDK/JDK/NDK versions, etc. ref:

Then there was several fixes that we needed to apply afterward:

As one can see, they're all fixed 🎉. But we havent republished all of the 119 android images yet!

Now the thing is I'm not exactly sure what's the right Android SDK/JDL/NDK for each versions.

How unity does it

When you install Unity from Hub or the installer, it magically asks you do you want the SDK and you get the right one. Installing unity from command line is sadly not as easy.

How we do it right now

Right now, the NDK versions is determined using these conditions which are based on unity's documentation: https://gitlab.com/gableroux/unity3d/-/blob/aa558bd/ci-generator/src/check_new_version.py#L83-88

Android SDK versions is hardcoded as a defeault value here: https://gitlab.com/gableroux/unity3d/-/blob/aa558bd/docker/unitysetup_2017-android.Dockerfile#L22 which is kind of locked to 28 as one can see

Somehow, I think ANDROID_CMD_LINE_TOOLS_VERSION (defined here and used in unity_version.yml) is not being used at all. It's not used in the Android SDK configuration part here:
https://gitlab.com/gableroux/unity3d/-/blob/aa558bd/docker/unitysetup-android.Dockerfile#L55

I think it should be used here, but it's hardcoded to an older version than what we currently expect:
https://gitlab.com/gableroux/unity3d/-/blob/master/docker/unitysetup-android.Dockerfile#L81

ANDROID_PLATFORM_VERSION is always set to 29 because of here:
https://gitlab.com/gableroux/unity3d/-/blob/aa558bd/ci-generator/src/check_new_version.py#L101

and also as default argument here:
https://gitlab.com/gableroux/unity3d/-/blob/aa558bd/docker/unitysetup-android.Dockerfile#L58

What we know about which versions to use

There was a very interesting discussion here:
https://gitlab.com/gableroux/unity3d/-/merge_requests/126#note_387524308

To summarize above discussion, u3d cli is a great tool, but it has some limitations as it does not support a lot of versions. It seems to pick the right versions so maybe we should have a look at how they do it.

Jonathan came up with a solution that allows installing unity from u3d here ():
https://gitlab.com/gableroux/unity3d/-/merge_requests/126#note_387639820

but since the tool doesn't support more recent versions, we have to think twice.

What are the options?

I think there are a few possible solutions:

1. Use u3d cli (The long solution)

This would imply many changes:

  • Fix some u3d cli upstream issues (mainly the ones that would allow installing more recent versions).
  • Update ci-generator to allow passing UNITY_VERSION because u3d cli needs it as an argument
  • We would have to branch the android build because unity's installation is not the same as base image (we could discuss this even more)

2. Inspire by u3d cli and figure out how to detect which SDK JDK NDK versions to use and where to find them

Maybe there's a quick win here, I haven't explored their source code too much yet

3. Keep doing it the way we're doing it, crawl unity's website to extract required versions or something like that.

I explored this solution a little. (see comment here https://gitlab.com/gableroux/unity3d/-/merge_requests/126#note_387550005)

Here are the scripts I quickly wrote which helps me recreating at least many versions for unity_versions.yml:
https://gitlab.com/gableroux/unity3d/-/merge_requests/130/diffs

4. Rebuild images with new fixes at least for now

This would be a good workaround for now. Even if versions are not matching what unity provides, it would at least work because right now, many android images just don't work (because they don't have the fixes mentioned above yet).

See https://gitlab.com/gableroux/unity3d/-/merge_requests/131


If you have any suggestion, I think I'm seeking for help here to get a good solution for android images 👀. There are probably better options than the ones I mentioned

Edited by Gabriel Le Breton