6

I need to setup Azure a devops pipeline to build and deploy my native Android application to Google Play store or App Center as App Bundle.

I could figure out to deploy an apk but need help to deploy app bundle(.aab). Any help would be appreciated.

riQQ
  • 9,878
  • 7
  • 49
  • 66
user_1989
  • 375
  • 4
  • 10

2 Answers2

10

Change the apkFiles to **/*.aab and pass the algorithms, -sigalg SHA256withRSA -digestalg SHA-256 as jarsignerArguments.

Like this:

- task: AndroidSigning@2
  inputs:
     apkFiles: '**/*.aab' 
     jarsign: true 
     jarsignerKeystoreFile: 'pathToYourKeystoreFile'
     jarsignerKeystorePassword: '$(jarsignerKeystorePassword)'
     jarsignerKeystoreAlias: '$(yourKeystoreAlias)'
     jarsignerKeyPassword: '$(jarsignerKeyPassword)'
     jarsignerArguments: '-sigalg SHA256withRSA -digestalg SHA-256'
     zipalign: true
Peter
  • 2,165
  • 2
  • 17
  • 25
  • 1
    When adding the task from the lists in devops you get AndroidSigning@3 by default. Note that you have to change it from 3 to 2 in order to get the jar version. – Gustaf Carleson Nov 08 '21 at 13:58
  • Don't forget to use $(system.defaultworkingdirectory)/app/build/outputs/*/*.aab as path for your apkFiles if the pipeline complains can't find your .aab files – saintjab Sep 01 '22 at 09:43
  • Also see my question please https://stackoverflow.com/q/76819786/4134215 – Taimoor Khan Aug 02 '23 at 12:17
4

You can use the Google Play - Release Bundle task to deploy app bundle(.aab). After the Google play extension is installed in your azure devops organization. You can add Google Play - Release Bundle task in your pipeline and configure the bundleFile field to the location of the generated .aab bundleFile. See below.

- task: ms-vsclient.google-play.google-play-release-bundle.GooglePlayReleaseBundle@3
  displayName: 'Release functionParam.ps1 to internal'
  inputs:
    serviceConnection: googleServiceEndPoint
    applicationId: applicationId
    bundleFile: **/*.aab 
    

Check out below tutorial to create a pipeline for your Android application

Build, test, and deploy Android apps

Update:

You can sign aab bundle using jarsigner command in azure pipeline. You might need to use download secure file task to use your keystore_file if you upload it to secure file. For example run below jarsigner command in a powershell task:

jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore my_keystor_file.keystore -storepass 'super_secret_keystore_pass' -keypass 'super_secret_alias_password' my-app-bundle.aab myKeyStoreAlias

See this thread for more information.

You can also use Xamarin.Android build task. And pass below arguements in Additional arguments for the build to package and sign the App Bundle:

-restore -t:SignAndroidPackage -p:AndroidPackageFormat=aab -p:AndroidKeyStore=True -p:AndroidSigningKeyStore=$(keystore.secureFilePath) -p:AndroidSigningStorePass=$(KeystorePassword) -p:AndroidSigningKeyAlias=$(KeystoreAlias) -p:AndroidSigningKeyPass=$(KeystorePassword)

See here for more information.

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
  • Thanks for the answer. The link provide is pointing to building and signing .apk prior distribution. For appbundle, I have used gradlew bundleRelease gradle task. However, AndroidSigning@2 would not help to sign the bundle right? – user_1989 Sep 10 '20 at 04:58
  • it seems AndroidSigning cannot sign the bundle. You can use jarsigner to assign the aab bundle instead. See above update. – Levi Lu-MSFT Sep 10 '20 at 07:00
  • After gradletask, I added the download task followed by a bash task with jarsigner script provided by you. But the jarsigner is unable to find the .aab file. Please can you help me with the exact task sequence I need to add. – user_1989 Sep 10 '20 at 10:24
  • Hi @user_1989 The task sequence of yours is correct. You probably specify the wrong path for aab file. You can check the log of gradle task to see where the aab file is generated. `$(System.DefaultWorkingDirectory)\path\to\aabfile` – Levi Lu-MSFT Sep 11 '20 at 01:46
  • Also see my question please – Taimoor Khan Aug 02 '23 at 12:17