Skip to main content

Deploying Android apps to Bitrise and Google Play

Abstract

You can deploy your Android apps to Bitrise or to Google Play by using our dedicated Steps and correctly configuring your project in Google Play Console.

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

You need a new service account created in the Google Play Console so that Bitrise can authenticate with Google Play Deploy during your build. The new service account has to be invited to Google Play Console as a user with the appropriate permission.

To set up your project for the first time:

  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 Setting up Google Play API access.

  2. Go through Setting up Google Play deployment for the first time.

Setting up Google Play API access

Grant the Google Play API access to your project by creating a service account and granting the necessary user permissions to the service account.

  1. Turn on the Google Play Developer API for your project: Enable the API.

  2. Create a service account on Google Cloud Platform: Create service accounts.

  3. Create a new JSON key for the service account: Create and delete service account keys.

    Instant download

    When you click Create at the end of the process, the service account JSON key is automatically downloaded. Make sure to save it as you cannot access or download it again!

  4. Invite your service account user on the Users & Permissions page in Google Play Console and grant the necessary permissions to be able to access and release apps on Google Play: Use a service account.

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.

Setting up Google Play deployment for the first time

Deploying to Google play publishes your app to Google's online store. When you do it for the first time, this requires a bit more work than simply deploying to bitrise.io. Once the necessary configurations are in place, it becomes very simple.

When configuring Google Play deployment for the first time, you need to link your Google Play Developer account to an API project, set up API access, and upload the service account JSON key to Bitrise.

  1. Upload the first AAB or APK 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.

    • Release management: Manage production releases, manage testing track releases.

    • Store presence: Edit store listing, pricing & distribution.

  5. As an optional step, you can add translations to your Store Listing: Translate & localize your app.

  6. Connect your Google service account to Bitrise.

Deploying an Android app to bitrise.io

In this section, we'll go through how to deploy your Android project to bitrise.io.

Deploying to bitrise.io means that the build artifacts generated during the build will be available for download once the build is finished. You can use this to test your Android app on your own test devices, for example.

To deploy your app to bitrise.io:

Workflow Editor

bitrise.yml

  1. Make sure your Workflow contains the Android Build Step to build your app.

    Optionally, you can build your app with the Gradle Runner Step. This requires a bit more configuration from you but allows for more extensive customization.

  2. Add the Deploy to Bitrise.io Step to your Workflow.

    Notifying other users

    You can use the Notify: User Roles and the Notify: Emails inputs of the Step to set up notifications about your deploy. Click the input names to reveal more information about how to configure them.

  3. Optionally, set the Enable public page for the App? input of the Step to true so the Step enables the public install page for your app.

  4. Run a build.

  1. Open the bitrise.yml file of your app.

  2. Make sure your Workflow contains the android-build Step to build your app.

    workflows:
      example-workflow:
        steps:
        - android-build@1:
    

    Optionally, you can build your app with the gradle-runner Step. This requires a bit more configuration from you but allows for more extensive customization.

  3. Set the module and/or variant input to tell the Step what to build.

    In this example, we're building a debug variant of the Android project.

    workflows:
      example-workflow:
        steps:
        - android-build@1:
            inputs:
            - variant: debug
        - deploy-to-bitrise-io: {}
  4. Add the deploy-to-bitrise-io Step to your Workflow.

    workflows:
      example-workflow:
        steps:
        - android-build@1:
            inputs:
            - variant: debug
        - deploy-to-bitrise-io: {}

    Notifying other users

    You can use the notify_user_groups and the notify_email_list inputs of the Step to set up notifications about your deploy:

    • The notify_user_groups input allows you to send notifications based on the access roles granted to users. For example, you can set the input to notify everyone with an Admin and a Developer role. Set multiple roles separated by a comma: - notify_user_groups: admins, testers.

    • The notify_email_list input only accepts Secrets, and the Secret should contain comma-separated lists of email addresses.

  5. Optionally, set the Enable public page for the App? input of the Step to true so the Step enables the public install page for your app.

  6. Run a build.

The Deploy to Bitrise.io Step will deploy the app. You can share the generated binary with your team members using the build’s URL.

Example 1. A bitrise.yml for deploying an Android app to Bitrise

In this example, we're building the debug variant of an Android app, and deploy it to bitrise.io, as.


Deploying to Google Play

Deploying to Google Play requires a signed APK or AAB file and the Google Play Deploy Step.

Workflow Editor

bitrise.yml

  1. If you're trying to deploy your app for the first time, make sure your Google Play configuration is set up correctly and that you uploaded your service account JSON key to Bitrise.

    Uploading the service account JSON key file

    We recommend uploading the service account JSON key to Bitrise but it is not mandatory: you can store it elsewhere and provide a direct link to it.

  2. Open the App settings page, and select Code Signing.

  3. On the Android tab, find the uploaded service account JSON key and copy the secret Env Var under its name.

    For example, BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL.

  4. Open your Workflow and add the Google Play Deploy Step to it.

  5. In the Service Account JSON key file path input, paste the Environment Variable you copied.

    Direct path to the service account JSON key file

    If you don't want to upload the service account JSON key to Bitrise, you can also add a file path right in the Step’s input field where the file path can be local or remote too:

    • For a remote JSON key file you can provide any download location as value, for example, https://URL/TO/key.json.

    • For a local JSON key file you can provide a file path url as value, for example, file://PATH/TO/key.json.

  6. In the Package name input, add the package name of your app.

  7. In the Track input, add the track where you want to deploy your APK (for example, alpha/beta/rollout/production or any custom track you set).

  1. If you're trying to deploy your app for the first time, make sure your Google Play configuration is set up correctly and that you uploaded your service account JSON key to Bitrise.

    Uploading the service account JSON key file

    We recommend uploading the service account JSON key to Bitrise but it is not mandatory: you can store it elsewhere and provide a direct link to it.

  2. Open your app's bitrise.yml file and add the google-play-deploy Step to it.

    deploy-workflow:
      steps: 
      - google-play-deploy: 
          inputs:   
    
  3. In the service_account_json_key_path input, you need to provide the path to the service account JSON key file.

    If you uploaded the file to Bitrise, you can find the Env Var storing its download URL in the Generic File Storage in the Workflow Editor.

    deploy-workflow:
      steps: 
      - google-play-deploy: 
          inputs:   
          - service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL"

    If you didn't upload your service account JSON key to Bitrise, you can set a direct path in the input. The file path can point to a local or a remote location.

    • For a remote JSON key file you can provide any download location as value, for example, https://URL/TO/key.json.

    • For a local JSON key file you can provide a file path url as value, for example, file://PATH/TO/key.json.

  4. In the package input, add the package name of your app.

    deploy-workflow:
      steps: 
      - google-play-deploy: 
          inputs:   
          - service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL"
          - package_name: myApp
  5. In the track input, add the track where you want to deploy your app binary (for example, alpha/beta/rollout/production or any custom track you set).

    deploy-workflow:
      steps: 
      - google-play-deploy: 
          inputs:   
          - service_account_json_key_path: "$BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL"
          - package_name: myApp
          - track: alpha

That’s all! Start or schedule a build and share the URL with external testers or distribute your app on an app store of your choice!