How to deploy your Android App to the Internal track in the Play Store Console using Fastlane
Are you a developer looking to streamline your app release process and get valuable user feedback before launching on the Google Play Store? Look no further than Fastlane — an efficient and powerful tool that simplifies the deployment of your Android apps. In this article, we’ll walk you through the process of uploading a beta release to Play Store Console using Fastlane. By the end, you’ll have a solid understanding of how to leverage Fastlane to distribute your app to beta testers effortlessly.
What is Fastlane?
Fastlane is an open-source tool designed to streamline and simplify the development and deployment process of mobile applications. It is specifically built for iOS and Android developers and offers a variety of useful features. Fastlane automates repetitive tasks such as certificate generation, app compilation, testing, app store deployment, and more.
How Install Fastlane?
I am using a machine with Fedora installed, so I will explain the steps to install Fastlane on this operating system. They vary slightly if you are using Windows or Mac.
Please check the official documentation for Fastlane configuration on Android.
Install neccesary dependencies:
1.
sudo dnf update
2.
sudo dnf install -y ruby-devel gcc make
3.
sudo dnf install gcc-c++
4. Finally, execute the following command to install Fastlane:
sudo gem install fastlane
Once the process has successfully finished, you can verify the version of Fastlane with the following command: fastlane -v
Now, we have Fastlane installed, navigate your terminal to your project’s directory and run:
fastlane init
The previous command will create a Gemfile and fastlane directory that contain Appfile and Fastfile.
Gemfile content
source "https://rubygems.org"
gem "fastlane"
~
~
~
A Gemfile is a file that lists the Ruby gems that your project depends on. It is used by Bundler, a tool that helps you manage your Ruby dependencies. When you run bundle install, Bundler will download and install the gems listed in your Gemfile.
Appfile content
json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("com.example.myamazingapp") # e.g. com.krausefx.app
~
~
According to the official fastlane documentation, the Appfile stores useful information that is used across all fastlane tools, such as your Apple ID or the application Bundle Identifier, to deploy your lanes faster and tailored to your project needs.
The
Appfile
has to be inside your./fastlane
directory.
Fastfile content
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do
gradle(task: "clean assembleRelease")
crashlytics
# sh "your_script.sh"
# You can also use other beta testing services here
end
desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(task: "clean assembleRelease")
upload_to_play_store
end
end
The
Fastfile
stores the automation configuration that can be run with fastlane.The
Fastfile
has to be inside your./fastlane
directory.TheFastfile
is used to configure fastlane.
Now, open the Google Play Console and navigate to the API access module.
Learn more about Publishing API
Terms of Service
Google Play Android Developer API
After accepting the terms and services you will be able to see the Google Play Developer APIs options we need to link an existing Google Cloud project or create a new one. For this example, we will create a new project from the Google Play console.
Next, let’s go to Google Cloud by clicking on the view in Google Cloud Platform option, which will open a new tab.
We will create a new Service Account, simply go to the main menu and select IAM & Admin > Service Accounts.
Later, click on the + CREATE SERVICE ACCOUNT button, which will take us to a view where we will need to enter the required information. After that, click on the CREATE AND CONTINUE button.
Select a role, then find and select Service Account User, and click the Done button.
Next we need to create a key to be able to authenticate and authorize the resources of the Service Account.
Click on the Service Account’s actions menu and select the Manage Keys option.
- Click ADD KEY -> Create New Key
- Make sure JSON is selected as the
Key type
, and click CREATE - Save the file on your computer when prompted and remember where it was saved to.
We return to the Google Play Console and click on Grant Access for the newly added service account at the bottom of the screen (you may need to click Refresh service accounts before it shows up)
Select the application for which the permissions will be granted.
Select the necessary permissions you want for the project. You can choose Admin to grant all permissions or manually select them, then click the Apply button.
Note: Make sure you’ve checked Releases section.
Click Invite user to finish
You can use fastlane run validate_play_store_json_key json_key:/path/to/your/downloaded/file.json
to test the connection to Google Play Store with the downloaded private key.
Up to this point, we have all the necessary configurations in the Play Store Console to be able to publish. However, it is necessary for us to create a lane with the steps to publish an Android version on the internal testing track.
Add the following lane to the Fastfile:
platform :android do
....
desc "Submit a new version to the internal track in the Google Play"
lane :deploy_internal do
gradle(task: "clean")
gradle(
task: 'bundle',
build_type: 'Release'
)
upload_to_play_store(track: 'internal')
end
end
Also, add the path to the JSON file to your Appfile.
json_key_file("path/to/your/play-store-credentials.json")
package_name("com.example.myamazingapp")
Bingo! Now we can publish versions to the internal track of the Play Store Console with Fastlane. Just run the following command:
fastlane deploy_internal
If you like my content and want to support my work, you can give me a cup of coffee ☕️ 🥰
Follow me in
- Twitter: @devjcastro
- Linkedin: devjcastro