3
votes

I'm setting up a build pipeline for a Xamarin Android app. I've got all the steps running that pull, restore, and build the project into an APK file. My next step is to sign the package before publishing.

What I have so far:

  • A .keystore file was created and uploaded to the Pipelines > Library > Secure Files. I verified that this file is being located correctly by providing an incorrect name and observing the results, then putting the correct name in.
  • Passwords are stored as secured variables in the pipeline itself.
  • File name and aliases are stored as variables on the pipeline file itself.
  • A YML task for AndroidSigning@3:

variables:
  buildConfiguration: 'Release'
  outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
  solution: '**/MySolution.sln'
  androidProject: '**/App.Android.csproj'
  keystoreFile: 'my.keystore'
  # keystoreAlias: 'aliasname'
  keystoreAlias: 'aliasName'

...

- task: AndroidSigning@3
  inputs:
    apkFiles: '$(outputDirectory)/*.apk'
    apksignerKeystoreFile: '$(keystoreFile)'
    apksignerKeystorePassword: '$(keystorePassword)'
    apksignerKeystoreAlias: '$(keystoreAlias)'
    apksignerKeyPassword: '$(keystorePassword)'

I've tried about everything I could think of to debug this, including some Powershell scripts in the pipeline to list out the binaries directory. When I do this, the $(outputDirectory) path expands out to D:\a\1\b\Release. The file contents in here include my .apk file, which is roughly 18MB in size. In this folder is also some .dll and .pdb files from the build.

When my pipeline gets to the Android Signing task, it begins validating the files in the .apk file:

2020-11-23T21:31:32.2526098Z [command]"C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.2\zipalign.exe" -v 4 D:\a\1\b\Release\com.COMPANY.PROJECT.apk.unaligned D:\a\1\b\Release\com.COMPANY.PROJECT.mobileapp.apk
2020-11-23T21:31:32.4654095Z Verifying alignment of D:\a\1\b\Release\com.COMPANY.PROJECT.mobileapp.apk (4)...
2020-11-23T21:31:32.4657624Z       49 AndroidManifest.xml (OK - compressed)
2020-11-23T21:31:32.4665566Z     1359 res/anim/abc_fade_in.xml (OK - compressed)
2020-11-23T21:31:32.4666075Z     1631 res/anim/abc_fade_out.xml (OK - compressed)
2020-11-23T21:31:32.4666429Z     1920 res/anim/abc_grow_fade_in_from_bottom.xml (OK - compressed)

It finished up all these checks on the files (or whatever its doing), then things break:

2020-11-23T21:31:32.4904751Z Verification succesful
2020-11-23T21:31:33.3789976Z [command]C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.2\apksigner.bat" sign --ks D:\a\_temp\mykeystore.keystore --ks-pass "pass:***" --ks-key-alias aliasname --key-pass "pass:***" --verbose D:\a\1\b\Release\com.COMPANY.PROJECT.apk"
2020-11-23T21:31:41.7116048Z Missing input APK
2020-11-23T21:31:41.7753859Z ##[error]Error: The process 'C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.2\apksigner.bat' failed with exit code 1
2020-11-23T21:31:41.7842464Z ##[section]Finishing: AndroidSigning

I'm at a loss at this point. The error only says it's missing the input APK, but as far as I can tell, the APK file is there. My only suspicion is that perhaps the process of verifying everything in the APK deletes the original APK?

Any help would be appreciated. I'm pretty lost at this point. I'm following a YML file set up by another team at my company and they didn't appear to have any problems with this by looking at their pipeline history...

2
That was exactly what the problem was. I actually discovered it yesterday afternoon after writing this post and forgot to update that that was the problem. Pipeline works now :)Zulukas

2 Answers

2
votes

Kindly check if you have any & and % in your password.

If you haven't properly escaped those chars, you should got this kind of issue.

Someone solved & and % in password by escaping them properly, please refer this link: Android Signing Task V3.0 fails when password string contains an ampersand

As a workaround, you could also try to upload another keystore with simpler password.

0
votes

The problem ended up being that I generated a random password with & and % characters in them. I solved this by just using a very long password of only random alphanumerics to avoid the hassle of escaping these characters.