Getting started with fastlane for Android

Installing fastlane

Homebrew Installer Script Rubygems
macOS macOS macOS or Linux with Ruby 2.0.0 or above
brew cask install fastlane Download the zip file. Then double click on the install script (or run it in a terminal window). sudo gem install fastlane -NV

Setting up fastlane

Navigate your terminal to your project's directory and run

fastlane init

You'll be asked to confirm that you're ready to begin, and then for a few pieces of information. To get started quickly:

  1. Provide the package name for your application when asked (e.g. io.fabric.yourapp)
  2. Press enter when asked for the path to your json secret file
  3. Answer 'n' when asked if you plan on uploading info to Google Play via fastlane (we can set this up later)

That's it! fastlane will automatically generate a configuration for you based on the information provided.

You can see the newly created ./fastlane directory, with the following files:

  • Appfile which defines configuration information that is global to your app
  • Fastfile which defines the "lanes" that drive the behavior of fastlane

The most interesting file is fastlane/Fastfile, which contains all the information that is needed to distribute your app.

Setting up supply

supply is a fastlane tool that uploads app metadata, screenshots and binaries to Google Play. You can also select tracks for builds and promote builds to production!

Setting it up requires downloading a credentials file from your Google Developers Service Account.

Collect your Google credentials

  1. Open the Google Play Console
  2. Select Settings tab, followed by the API access tab
  3. Click the Create Service Account button and follow the Google Developers Console link in the dialog
  4. Click the Create Service account button at the top of the developers console screen
  5. Provide a name for the service account
  6. Click Select a role and choose Project > Service Account Actor
  7. Check the Furnish a new private key checkbox
  8. Select JSON as the Key type
  9. Click Create to close the dialog
  10. Make a note of the file name of the JSON file downloaded to your computer
  11. Back on the Google Play developer console, click Done to close the dialog
  12. Click on Grant Access for the newly added service account
  13. Choose Release Manager from the Role dropdown
  14. Click Add user to close the dialog

Configure supply

Edit your fastlane/Appfile and change the json_key_file line to have the path to your credentials file:

json_key_file "/path/to/your/downloaded/key.json"

Fetch your app metadata

If your app has been created on the Google Play developer console, you're ready to start using supply to manage it! Run:

fastlane supply init

and all of your current Google Play store metadata will be downloaded to fastlane/metadata/android.

Due to limitations of the Google Play API, supply can't download existing screenshots or videos.

What's next?

fastlane is ready to generate screenshots and automatically distribute new builds! To learn more, check out:

Use a Gemfile

It is recommended that you use a Gemfile to define your dependency on fastlane. This will clearly define the used fastlane version, and its dependencies, and will also speed up using fastlane.

  • Install bundler using sudo gem install bundler
  • Create a ./Gemfile in the root directory of your project with the content
source "https://rubygems.org"

gem "fastlane"
  • Run [sudo] bundle update and add both the ./Gemfile and the ./Gemfile.lock to version control
  • Every time you run fastlane, use bundle exec fastlane [lane]
  • On your CI, add [sudo] bundle install as your first build step
  • To update fastlane, just run [sudo] bundle update