Fastlane for Android — Automate Everything (Part 1)

Chan Bo
Chan Bo
Mar 15 · 3 min read
Photo by SpaceX on Unsplash

As you may know, every time we release or update android app, we have build sign apk and add to store then add description, screenshots, etc. It’s the same things but you have to done every time you release or update your android app.


That’s why Fastlane have come up here. Fastlane have 4 base features:

  1. Automate Screenshots
  2. Beta Deployment
  3. Play Store Deployment
  4. Code Signing (For IOS)

I will Implement it one by one. But before the implementation, let’s start setting up Fastlane first.

Install Fastlane

install the latest Xcode command line tools:

$ xcode-select --install

install fastlane using

  • RubyGems: $ sudo gem install fastlane -NV
  • Homebrew: $ brew cask install fastlane

After you have installed Fastlane successfully, add the below lines to your shell profile (typically ~/.bashrc or ~/.bash_profile or (if you are like me) ~/.zshrc).

export PATH="$HOME/.fastlane/bin:PATH"
export LC_ALL=en.US.UTF-8
export LANG=en.US.UTF-8

That’s it about Fastlane installation.

If you are installing via RubyGems you should install Gem first before install Fastlane.

If you are installing via Homebrew, make sure you have installed brew before installing Fastlane.


Note: If you are getting error while installing Fastlane from this blog, you can follow the instruction from the Fastlane official website to make sure it’s all up-to-date.


Setting up Fastlane

Navigate to your project directory then

$ fastlane init

This command is to initialize fastlane to your project and it will require your app package name. Then it will ask for Path to the json secret file but you can skip it first, I’ll explain later on Play Store Deployment section and also skip for Download existing metadata and setup metadata managment.

After finish initialize fastlane, you will see fastlane folder and inside that it has two files:

  • Appfile: where you put your package name and json secret file
  • Fastfile: where you write your configuration

These code is auto generated by Fastlane when you initialize fastlane.

Config Walkthrough

Syntax of writing config in fastlane

desc "Your lane description"
lane :your_lane_name do
...
...
end

As you can see in our Fastfile now have several lane. The first lane is lane :testinside that lane has gradle(task:"test").It mean this lane is going to run unit test for your whole project.

To run it using $ bundle exec fastlane test

After that you will see your result whether it passed or failed like the picture above.

Finally you have run your first fastlane.


That’s all for now. In next blog I will show you how to use Automate Screenshot in our android app. Let me know if you have any problem! 😍

References

Open Knowledge

Blog for Sharing Knowledge

Chan Bo

Written by

Chan Bo

Open Knowledge

Blog for Sharing Knowledge

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade