.NET MAUI Android Build Fails on GitHub Actions with jarsigner.exe Exited with Code 1

303 views Asked by At

Summary:

I'm attempting to build and sign a .NET MAUI Android app using GitHub Actions. While everything works perfectly on my local machine, and the GitHub Actions workflow runs smoothly up until the signing stage, I encounter an error related to jarsigner.exe during the build process on GitHub Actions.

The problem:

Error message

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.68\tools\Xamarin.Android.Common.targets(2335,2): error MSB6006: "jarsigner.exe" exited with code 1. [D:\a\App.name\App.name\App.name\App.name.csproj::TargetFramework=net7.0-android]

Last part of the workflow

- name: Setup Java
  uses: actions/setup-java@v3
  with:
    distribution: 'microsoft'
    java-version: '17'

- name: Build
  run: dotnet build App.name/App.name.csproj -c Release -f net7.0-android /p:AndroidSigningKeyPass=${{ secrets.KEYSTORE_PASSWORD }} /p:AndroidSigningStorePass=${{ secrets.KEYSTORE_PASSWORD_STORE }} --no-restore

Additional Information:

  • The keystore file is correctly decrypted and available in the GitHub secrets
  • Actions environment. The Java version being used is 17 from the
  • Microsoft distribution. All preceding steps in the workflow, including dependency restoration and MAUI workload installation, complete without issues. Has anyone encountered a similar issue or can provide insights into what might be causing this error with jarsigner.exe on GitHub Actions?

Should I perhaps share the the entire .yaml file?

1

There are 1 answers

2
AllramEst On BEST ANSWER

Ok, so I solved it.

Removing the keystore config in the .csproj file and adding them to the command made it worked.

  run: dotnet build App.name/App.name.csproj -c Release -f net7.0-android /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=${{secrets.KEYSTORE}} /p:AndroidSigningKeyAlias=${{ secrets.KEYSTORE_ALIAS }} /p:AndroidSigningKeyPass=${{ secrets.KEYSTORE_PASSWORD }} /p:AndroidSigningStorePass=${{ secrets.KEYSTORE_PASSWORD }}
--no-restore

Edit:

Had to remove /p:AndroidKeyStore=true for it to not throw errors.

Edit 2: Actually I added /p:AndroidKeyStore=true back. The real problem was in wich environment I was running the gpg command for the keystore.