CI/CD for Android - Google Play Authorization

May 2, 2024·

5 min read

As we have discovered in the previous section, once we create (or log in to an existing) Google Play Developer Account, we will land on a page that looks like this

Screenshot 2023-07-12 at 11.06.14.png

It means that we have access to the Developer Console, so we can already start deploying apps to Google Play.

Your Google Play Developer Console is a unique instance where you can deploy your apps.

The important part regarding the CI/CD setup is to be able to deploy to this console automatically. But how would our potential system know which Developer Console is ours? How do we link to our unique instance?

That's where the API access comes into play. On the left-hand side menu, there is an item called API access, which is the starting point for our next steps in this setup.

Important: If you are not an owner of the Google Play Developer Account, you will not have the rights to access this menu and therefore it won't be shown at all. In that case, you will need to use the owner account to login to the console.

The way we use the Google Play Developer Console APIs is by using a single file (at the moment of creating this course it comes in a JSON format) that contains information about our unique instance and authorization to use the APIs.

Our job is to obtain that file so that we can use it.

  1. Open the API access from the side menu

  2. You might be prompted with a question about Google Cloud Project with 2 options to choose from: Link an existing | Create new

    • For the sake of this course, we will work on a new one, so select Create new
  3. You will be faced with a screen similar to this one :

    screencapture-play-google-console-u-0-developers-5909141819248237050-api-access-2023-07-23-10_33_10.png

    Note that at the moment you are going through this course, the page might differ as it is software made by Google and they are continuously improving it.

    The page contains a few sections, one of which is the APIs. You will see the Google Play Android Developer API turned ON. If that's not the case - don't worry, it will get there eventually.

  4. Next, we focus on the Credentials section, Service accounts specifically. Our goal is to create a new service account. In the example above we can see already an item in there, as that is something I have created before. If you are setting up for the first time, the list will be empty. In both cases, it should show a button/link to View in Google Cloud Platform. If that's not the case, by clicking on Learn how to create service accounts we will get offered a link to open the Google Cloud Platform.

    Screenshot 2023-07-23 at 14.01.08.png

    The main goal is to get to the Google Cloud Platform, and it is irrelevant how we will get there. It's a different system where we can manage the APIs we will use and the access to them. This is how does it look like:

    Screenshot 2023-07-23 at 14.06.26.png

    As we can see on the left top side, we have the APIs & Services page currently opened. There is also a hamburger menu available where we can go to different pages. Go ahead and click on the menu, then select IAM & Admin

    Screenshot 2023-07-23 at 14.18.51.png

  5. From this submenu, select Service Accounts. It will show a page like this

    Screenshot 2023-07-23 at 14.21.51.png

    As we can see here, I already have created a service account before, and we can see it listed here. If you are setting it up for the first time, this list will be empty. Go ahead, and click on the + CREATE SERVICE ACCOUNT button on the top middle of the page. You will face a form like this:

    Screenshot 2023-07-23 at 14.23.46.png

  6. Fill out the form according to your needs/desires. If you are about to deploy multiple apps on the same google play account (which is what most people and companies do), you can choose more generic data. On the other hand, if you want to be more strict, you can name the things according to the project you are working on, and then create multiple items as you need. That's also an option.

    The following step asks to grant permissions to the service account. I recommend granting Owner permissions, but again - choose according to your needs.

    Screenshot 2023-07-23 at 14.26.35.png

    Once you are done and you have the service account created, you will be taken back to the start page where you will see your new service account listed, like so

    Screenshot 2023-07-23 at 14.29.51.png

    As we can see here, I have no Key ID for my newly created account. Let's go ahead and click on it to open it in detail. You have to click on the left-side email-like link to open it. It will show the detail page, like so:

    Screenshot 2023-07-23 at 14.31.42.png

  7. Click on the KEYS section at the top to see the keys. Initially, we have no keys so the page is empty

    Screenshot 2023-07-23 at 14.34.22.png

    Go ahead and click on ADD KEY drop-down button, and select Create new key. You will be prompted to choose the type of the key

    Screenshot 2023-07-23 at 14.35.53.png

    Make sure the JSON type is selected (which is also the recommended type) and click on CREATE. It will download a JSON file to your preferred folder for downloads (mine is Desktop).

    Note: Depending on your browser, it might not automatically download the JSON. I have seen issues with some browsers, but in general, Chrome, Firefox and Safari work fine.

    Screenshot 2023-07-23 at 14.39.38.png

    This JSON file is the file we need to use the Google Play Developer APIs. Beware that you cannot re-download this file. If you lose it before you finish the whole setup of your CI/CD, you will have to create a new key. The good thing is that you don't have to re-create the account tho. Only the key. As we can see now, the newly created key is listed as well.

    Screenshot 2023-07-23 at 14.43.04.png

    With this step, we have completed a huge part of the preparation for the whole CI/CD setup. Make sure you keep the JSON file safe as we will need it together with the Keystore when setting up the repository. Next up: the Keystore Setup

    Go to the Keystore Setup