Why we need the Google Play service connection?
We use the service connections to connect an external service for the purpose to execute tasks in a job. To release a Xamarin.Android app (or any other Android app in general) more particularly an executable file .apk/.aab through Azure DevOps we have two authentication methods to connect to Google Play store. By Service connection or by using the Json Auth File. For both methods the first few steps are the same and in the end decide which method we prefer more. To achieve that we need first to set up the Service account. (If you want to learn more on service accounts read the link: Google Cloud – Service accounts
Create Service account on Google Play Console
Navigate to Google Play Console. Note that to make these changes we need to have owner role. Once logged in with the correct role follow these steps:
- Select Settings from the menu.
- From Developer account menu choose API access Sub Menu
- At the bottom section Service Accounts choose Create Service Account. We will be provided with a few steps that need to be done in order to create a service account. Let’s see them in details:
- Navigate to Google Cloud – Service accounts
- Here we choose the project we want to create service account for
- Press on +Create service account
- Add service account name, we can see that the Service account ID is created for us, we can make some changes by editing the field independently
- Service account description is optional so we can leave it empty for now
- By clicking create we will proceed on the second steps
- To have full access to all resources choose for role: Project -> Owner
- By clicking Continue we will proceed to the last step
- Here you can grant access for more users or groups. But since it is optional let’s leave it empty for now.
- By clicking Done new service account will be created.
- Navigate to Service account details by clicking on created service account.
- At the bottom under Key section choose Add Key
- Choose JSON
- The Json File will be automatically created and downloaded locally on our PC
- Get back to Google Play Console, we can now see that under Service accounts new account was created for us. Just accept the premissions, and add some edits if needed.
Authorize Azure DevOps with Google Play
- Navigate to the release task: Google Play – Release Bundle on the Release pipeline in Azure DevOps. To see more detailed steps on how to come to this point take a look at this post: Release Android App Bundle for Xamarin.Android apps using Azure DevOps
- Under Authentication method choose the preferred method for your pipeline
Authorize Azure DevOps with Google Play using the JSON Auth File
- If you you choose JSON Auth File the new required field JSON key path will appear.
- Set the Json file path. See on this link how to add the JSON file in the Release Pipeline: Add Google JSON Auth file in Azure DevOps Release Pipeline
Authorize Azure DevOps with Google Play using Service connection
- If you you choose Service connection the new required field Service connection will appear.
Here we have two options, to create a connection for this particular project by clicking the +New button or to add global Service by clicking on Manage. If you have multiple projects on the same Google play console account I would prefer setting that is in the Service connection under Project Settings – by clicking Manage.
- By choosing the second option, we will be directed to Project settings -> Service connections
- Search for Google Play and choose it. Click Next. Open the downloaded .json file
- In Service Account E-mail copy the client_email value from the .json file
- In Private Key copy the private_key value from the .json file
- In Service connection name add Connection Name you find representative for this connection
- Description is optional so let’s leave it empty by now
- Navigate back to Release task and refresh the Service connection field. The connection will appear. Choose it and save.