Tips for Publishing a Flutter app on Google Play Store
Tags: flutter, mobile, google, android
Published: 2020-09-15 00:16:29

Recently, I published my very first app on Google Play Store. This post presents a set of __tips__ that I hope to be useful for the publication of your mobile app. I divided this post into three parts. Tips are presented on each stage of the application lifecycle:

__Creation of a New Flutter Project__ - right from Flutter project creation we must have in mind that the app will be published. Therefore, GitHub and CI/CD tool shall be introduced in this stage;

__First publishing__ - first publishing of the app at the Play Store;

__Update publishing__ - once the app is published, we may want to update the app.

### __During Creation of a New Flutter Project__ ###
__Tip 1__ - Introduce __Github__ to your project. Create a repository on Github and make code changes on Git branch. Since I`m  not working in a team, and this is the first app, I will do all my code changes on master branch (it is up to you to decide to have more than a branch). In the third part, where I will update my app, I will create a dev branch (we will see it soon).

__Tip 2__ – __Setup a CI/CD__, linking Github repository to Codemagic. I use Codemagic but it is really up to you to decide which CI/CD tool to use. Codemagic enables you to automatically publish your app to the internal, alpha, beta and production tracks on Google Play. Since I don't like to do the same thing twice, I always look to automate processes as much as I can.

###__First Publishing__###
Since we are at this stage, I will assume that all the coding is done and ready for publishing. Codemagic can be very useful to setup code signing and configure the services we want to use for receiving build notifications (email by default).
At this stage we haven't published our app on Google Play yet, so we must create an entry for our app in Google Play Console and manually upload the very first version of the app before we can automate publishing using Codemagic.
 
__Tip 3__ - __Follow the Codemagic documentation__, it`s really explanatory and easy to follow. 
[Codemagic Documentation](https://docs.codemagic.io/)
Regarding above documentation, I have chosen __Option 1. Configure signing following Flutter's documentation__. 
If the build finishes successfully, generated artifacts (in our case, __app-release.apk__) will be published to the provided email (by default). This apk will be uploaded (drag-and drop) in the next phase (Tip 4).

__Tip 4__ - __Go to Google Play Console__ and Create application (one time $25 registration fee which you need to pay before you can upload an app). Great video to follow (__6:60 – 11:30__): [Deploying Flutter App To Playstore](https://www.youtube.com/watch?v=NFTaWkUtD34)

__Tip 5__ – __Be patient__, the first publishing can take long. For my case it took __4 long days__. I have chosen beta release.

###__Update Publishing__###
Now that the app (beta release) is published, I' m going to do modifications, but in a __new Github branch__ - the __dev branch__. Once you are done with your development work on the “dev” branch, and validated your changes, you may want to merge the changes to the master branch. 
Note that the publishing on Google Play Store feature of Codemagic was not used so far.

__Tip 6__ - __Merge Dev Branch to Master Branch__. See article [5 Steps for Code Changes Only on Git Branch and Merge to Master Once Done](https://www.thegeekstuff.com/2019/03/git-create-dev-branch-and-merge/)

__Tip 7__ - Returning to Codemagic CI/CD to __automate the publishing at Google play store__ after first publishing (previously done)  – follow the codemagic documentation: [Codemagic - publishing on Google Play](https://docs.codemagic.io/publishing/publishing-to-google-play/)

Codemagic Publishing Report (you can ckeck it at the app github repository):
_== Gathering artifacts ==
== Publishing artifacts ==
Publishing artifact app-release.apk
Publishing artifact firebase_core-release.aar
Publishing artifact firebase_storage-release.aar
Publishing artifact mapping.txt
Publishing app-release.apk to Google Play
Published app-release.apk to track beta
Publishing proguard mapping mapping.txt to Google Play_

__Tip 8__ - __Take a long coffee or a snap__: Updated publishing on google play store took almost 12 hours.


__You can check the app on the Google Play Store at:__
https://play.google.com/store/apps/details?id=com.barqueira.cicd.demo

__Github repository of the app:__
{% github lbarqueira/cicd_demo %}