Reputation: 61351
I am trying to set up a build pipeline for the Xamarin Android app using AzureDevops Pipeline.
The step that is causing my hair to go thin and grey is Signing and Zipaligning.
For signing, I have created a self-signed key using:
keytool -genkeypair -v -keystore keystore.keystore -alias keyAlias -keyalg RSA -keysize 2048 -validity 10000
Then I have added keystore.keystore
to azureDevOps secure files location and enabled it for all pipelines
I then set the signing step in the following way:
task: AndroidSigning@3
inputs:
apkFiles: '**/*.apk'
apksign: true
apksignerKeystoreFile: 'keystore.keystore'
apksignerKeystorePassword: '12345678'
apksignerKeystoreAlias: 'keyAlias'
apksignerKeyPassword: '12345678'
apksignerArguments: '--verbose'
zipalign: true
The pipeline runs fine without errors, produces artifacts:
Here's part of the log for the signing step:
Starting: AndroidSigning
============================================================================== > Task : Android signing Description : Sign and align Android
APK files Version : 3.181.0 Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/android-signing
============================================================================== > /Users/runner/Library/Android/sdk/build-tools/30.0.3/zipalign -v 4/Users/runner/work/1/s/xxx.MobileApp/xxx.MobileApp.Android/obj/Release/android/bin/com.xxx.xxx.mobileapp.apk.unaligned
/Users/runner/work/1/s/xxx.MobileApp/xxx.MobileApp.Android/obj/Release/android/bin/com.xxx.xxx.mobileapp.apk
Verifying alignment of
/Users/runner/work/1/s/xxx.MobileApp/xxx.MobileApp.Android/obj/Release/android/bin/com.xxx.xxx.mobileapp.apk
(4)...
49 AndroidManifest.xml (OK - compressed)
...
28095862 META-INF/proguard/androidx-annotations.pro (OK - compressed)
Verification succesful
/Users/runner/Library/Android/sdk/build-tools/30.0.3/apksigner sign
--ks /Users/runner/work/_temp/keystore.keystore --ks-pass pass:12345678 --ks-key-alias keyAlias --key-pass
pass:12345678 --verbose
/Users/runner/work/1/s/xxx.MobileApp/xxx.MobileApp.Android/obj/Release/android/bin/com.xxx.xxx.mobileapp.apk
Signed Finishing: AndroidSigning
however when I try to upload APK to play store to "Create internal testing release"
I get the error:
You uploaded an APK that is not zip aligned. You will need to run a zip align tool on your APK and upload it again.
which makes me throw my hands in the air, and shake the head.
Upvotes: 0
Views: 405
Reputation: 61351
The cause was a lack of internal mental capacity as usual. I didn't set the output dir. After changing apkFiles: '**/*.apk'
to apkFiles: '$(outputDirectory)/*.apk'
it all worked.
task: AndroidSigning@3
inputs:
apkFiles: '$(outputDirectory)/*.apk'
apksign: true
apksignerKeystoreFile: 'keystore.keystore'
apksignerKeystorePassword: '12345678'
apksignerKeystoreAlias: 'keyAlias'
apksignerKeyPassword: '12345678'
apksignerArguments: '--verbose'
zipalign: true
Upvotes: 1