game-ci / unity-builder

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

Install non builtin target android sdk #581

Closed eronnen closed 1 year ago

eronnen commented 1 year ago

Context

I try to build android APK on Unity 2022, with API 29 target. By default the android sdk that is shipped with unity comes with 30 and 31 target sdk, so I get the following error:

Android SDK does not include your Target SDK of 29.
Please use the Android SDK Manager to install your target SDK version. Restart Unity after SDK installation for the changes to take effect.

Suggested solution

add a parameter to the build that will install the target sdk with:

/opt/unity/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/tools/bin/sdkmanager  "platforms;android-29"
eronnen commented 1 year ago

apparently can be fixed with the androidTargetSdkVersion parameter and ANDROID_SDK_MANAGER_PARAMETERS environment variable, but the sdkmanager invocation fails with:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    at com.***.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
    at com.***.repository.api.SchemaModule.<init>(SchemaModule.java:75)
    at com.***.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
    at com.***.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
    at com.***.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
 Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 5 more