Deploy to Google Play using fastlane

Building your app

fastlane takes care of building your app by delegating to your existing Gradle build. Just add the following to your Fastfile:

lane :playstore do
  gradle(
    task: 'assemble',
    build_type: 'Release'
  )
end

Try running the lane with:

fastlane playstore

When that completes you should have the appropriate APK ready to go in the standard output directory. To get a list of all available parameters for the gradle action, run:

fastlane action gradle

Uploading your APK

To upload your binary to Google Play, fastlane uses a tool called supply. Because supply needs authentication information from Google, if you haven't yet done the supply setup steps, please do those now!

With that done, simply add a call to supply to the lane you set up above:

lane :playstore do
  gradle(
    task: 'assemble',
    build_type: 'Release'
  )
  supply # Uploads the APK built in the gradle step above
end

This will also upload:

  • App metadata from fastlane/metadata/android if you previously ran fastlane supply init
  • Expansion files (obbs) found under the same directory as your APK as long as:
    • They are identified by type as main or patch by containing main or patch in their file names
    • There is at most one of each type
  • Screenshots from fastlane/metadata/android if you previously ran screengrab

If you would like to capture and upload screenshots automatically as part of your deployment process, check out the fastlane screenshots for Android guide to get started!

To gradually roll out a new build you can use:

lane :playstore do
  # ...
  supply(
    track: 'rollout',
    rollout: '0.5'
  )
end

To get a list of all available parameters for the supply action, run:

fastlane action supply