mcExchange
mcExchange

Reputation: 6497

How to upload android app via google play API?

I'd like to upload may android apps (.aab files) automatically to google play console (creating a new internal test) using a bash script (part of my CI/CD pipeline).

On a high level it looks like I have to

  1. create a sevice project on google cloud
  2. link that project to google play console

However, I'm stuck at step 2. All the documentation I found on this seems to be outdated.

For example according to this page, under the "Service account overview" section, I should be able to see the newly created service account:

This is what I should see in Google Play Console

However, when I click on "API Access" under Google Play Console it's pretty much empty:

enter image description here

This sounds like a well documented task but it isn't. Any hints or up-to-date step by step guide for doing this?

Upvotes: 3

Views: 1978

Answers (1)

mcExchange
mcExchange

Reputation: 6497

Here is a rough solution of how I fixed my problem:

  1. create a sevice project on google cloud (follow this tutorial)

  2. link that project to google play console

In Google Play Console → user management and permissions → add new google cloud service account

  1. Install Fastlane (I'm on Windows and installed Ruby via "rubyinstaller-devkit-3.2.2-1-x64.exe")

  2. Install fastlane via ruby

    gem install fastlane -NV

    fastlane init

    fastlane supply init

(This last command should download metadata of your app if I remember correctly !?)

  1. Download google cloud json authentication key (explained in the video above, min 2:50): my-authentication-key.json

    gcloud auth activate-service-account --key-file=my-authentication-key.json

  2. Run fastlane authentication command

    fastlane run validate_play_store_json_key my-authentication-key.json --verbose

  3. Create a Fastfile

    mkdir fastlane

    touch fastlane/Fastfile

Paste the following content into the file:

# Fastfile                                                                                                                                                                                                                                                                             
default_platform(:android)                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                       
platform :android do                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                       
  desc "Deploy a new version to the Google Play"                                                                                                                                                                                                                                       
  lane :deploy_to_play_store do |options|                                                                                                                                                                                                                                              
    aab_path = options[:aab] # Path to the AAB file                                                                                                                                                                                                                                    
    metadata_path = options[:metadata_path] # Path to metadata directory                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                       
    upload_to_play_store(                                                                                                                                                                                                                                                              
      track: 'internal', # Track for the release                                                                                                                                                                                                                                       
      aab: aab_path, # Path to the AAB file                                                                                                                                                                                                                                            
      release_status: 'completed', # Release status (draft, inProgress, halted, completed)                                                                                                                                                                                             
      metadata_path: metadata_path, # Path to the metadata directory                                                                                                                                                                                                                   
      skip_upload_apk: true, # Explicitly skip uploading APK files                                                                                                                                                                                                                     
      skip_upload_metadata: true, # Skip uploading other metadata                                                                                                                                                                                                                      
      skip_upload_images: true, # Skip uploading images                                                                                                                                                                                                                                
      skip_upload_screenshots: true, # Skip uploading screenshots                                                                                                                                                                                                                      
      # Any additional parameters you need                                                                                                                                                                                                                                             
    )                                                                                                                                                                                                                                                                                  
  end                                                                                                                                                                                                                                                                                  
end  
  1. Upload an aab file to Google Play Console

fastlane android deploy_to_play_store aab:MyAndroidApp.aab metadata_path:metadata

Upvotes: 1

Related Questions