GitHub

Deploying Android apps

Last updated at 2020-05-26

This guide describes how you can add your Android project to bitrise.io and deploy the APK built from your project to Google Play Store.

In this guide, you will learn how to:

Adding your Android app on bitrise.io

Setting up your first project

  1. Register a Google Play Developer Account. If you already have a Google Play Developer account, and have already deployed your app to Google Play Store, skip to Set up Google Play API access.
  2. Go through the Prepare & roll out steps.

Setting up Google Play API access

  1. Link your API project by Creating a new API project or Using an existing API project.
  2. Click on Create a new service account. The instructions will redirect to Google API Console. Specify a service account name. No roles are needed for the service account.
  3. Create a private key (JSON format) and download it now because you will need it later.
  4. Grant the necessary permissions to the service account on the Play Console.

Check out the Google Play Developer API guide if you need more information on the process.

You have successfully prepared your Google Play Console project. A services credential account has been created which is authorized to manage your releases.

Deploying to bitrise.io

The Deploy to bitrise.io - Apps, Logs, Artifacts Step attaches all the generated artifacts to your build and uploads them into the  APPS & ARTIFACTS tab on your Build’s page. By default, the value of the Enable public page for the App? input field is set to true. This way, once the build runs, a public install page will be available with a long and random URL which can be shared with others who are not registered on Bitrise.

You can notify user groups or individual users that your APK file has been built by specifying roles and/or email addresses. You can share the app’s public install page with anyone if you set the following input fields:

  1. Go to the Deploy to bitrise.io Step.
  2. In the Notify: User Roles input field, add the role (for example, testers, developers, admins) so that only those get notified who have been granted with this particular role.
  3. Or fill out the Notify: Emails input field with email addresses of the users you want to send the URL to. Make sure you set those email addresses as secret Environment Variables! These details can be also modified under Notifications if you click the eye icon next to your generated APK file in the APPS & ARTIFACTS tab. Here you can check the URL by clicking Open Public install page.

How can I get notified?

You can get a notification email about a successful or failed build, if you click the Watch icon above the Start/Schedule a Build purple button on your Build’s page.

Deploying to the Google Play Store

Before you’d use the Google Play Deploy Step, make sure you have performed the following tasks:

  1. Upload the first APK or AAB manually to Google Play using the Google Play Console.
  2. Link your Google Play Developer Console to an API project.
  3. Set up API Access Clients using a service account: Please note when you create your service account on the Google Developer Console, you have to choose json as Key Type.
  4. Grant the necessary rights to the service account with your Google Play Console. Go to Settings, then Users & permissions, then Invite new user. Due to the way the Google Play Publisher API works, you have to grant at least the following permissions to the service account:
    • Access level: View app information, Create & edit draft apps.
    • Release management: Manage production releases, manage testing track releases, Manage testing track configuration.
  5. As an optional Step, you can add translations to your Store Listing. To allow the Google Play Deploy Step to assign your whatsnew files to the uploaded APK version, visit the Translate & localize your app guide and add translations to your Store Listing section.

Now let’s head back to Bitrise and finish off the deploy configuration!

  1. Log in to bitrise.io.
  2. Select your project and go to Workflow Editor.
  3. Click the Code Signing tab.
  4. Upload the service account JSON key into the GENERIC FILE STORAGE.
  5. Copy the env key which stores your uploaded file’s URL.

    For example:

    BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL

  6. Go back to your Workflow Editor and add the Google Play Deploy Step to the end of your Workflow.
  7. Fill out the required input fields which are:
    • Service Account JSON key file path: this field can accept a remote url so you have to provide the environment which contains your uploaded service account JSON key. For example: $BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL.
    • Package name: the package name of your Android app.
    • Track: the track where you want to deploy your app (for example, internal/alpha/beta/production or any custom track you set).

You can use the Play Console UI to promote apps to other tracks (for example, an app uploaded to internal testing can be released on alpha track).

The final configuration looks like this:

workflows:
deploy:
  steps:
  - activate-ssh-key@4.0.5:
      run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
  - git-clone@4.0.17: {}
  - cache-pull@2.0.1: {}
  - script@1.1.5:
      title: Do anything with Script step
  - install-missing-android-tools@2.3.7: {}
  - android-build@0.10.0:
      inputs:
      - project_location: $BITRISE_SOURCE_DIR
      - module: "app"
  - sign-APK@1.4.1: {}
  - google-play-deploy@3.0.1:
      inputs:
      - package_name: io.bitrise.googleplay
      - service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL"
      - track: alpha
  - deploy-to-bitrise-io@1.9.4: {}
  - cache-push@2.2.3: {}

Your workflow is ready for deploying your app automatically to Google Play Store. Once the app is tested and generated, you can upload it to Google Play Store.