ARTICLE AD BOX
I'm trying to build a .NET Android App in my Gitlab CI pipeline, but the "official" way I thought I found does not seem to work or I misunderstood something there.
I used the Android App template, not the MAUI one. As far as I understand, I basically need to start from the dotnet sdk image, install the dotnet android workload, install android sdk and jdk, and then just call dotnet build or whatever I want.
When I first failed to do this, dotnet very helpfully sent me to [Install .NET for Android dependencies](https://learn.microsoft.com/en-us/dotnet/android/getting-started/installation/dependencies), which seems to me very helpful as it says I just call
dotnet build -t:InstallAndroidDependencies -p:AndroidSdkDirectory=$CI_PROJECT_DIR/android-sdk -p:JavaSdkDirectory=$CI_PROJECT_DIR/java-sdk -p:AcceptAndroidSdkLicenses=TrueAnd the magic MSBuild target will install both android sdk and jdk for me.
Except it doesn't. As far as I can tell, it has an issue about a user or something:
/usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/36.1.30/tools/Xamarin.Installer.Common.targets(19,3): error : Exception caught while unzipping '/tmp/tmp81YXys.tmp' in '/tmp/7e41a2ed'. System.InvalidOperationException: Internal error: CommonUtilities.Helpers.UserName must have a valid value [/builds/Regenhardt/dual-camera/DualCamera/DualCamera.csproj]So I figure, I'm probably not the first person to build a .NET Android App on Gitlab CI, there has to be a best practice or something kinda straight forward to build a .NET Android App in a CI pipeline?
Here's my current pipeline config where I added the build target to the actual build call because I though dotnet has to be smart enough by now, except of course it doesn't work because then I wouldn't be here:
image: mcr.microsoft.com/dotnet/sdk:10.0 stages: - build before_script: - dotnet workload install android build: stage: build script: - dotnet build DualCamera/DualCamera.csproj -t:InstallAndroidDependencies -p:AndroidSdkDirectory=$CI_PROJECT_DIR/android-sdk -p:JavaSdkDirectory=$CI_PROJECT_DIR/java-sdk -p:AcceptAndroidSdkLicenses=True