DEV Community

Cover image for FlutterFlow | Codemagic CI with Google Play Store
Tarlan Isaev 🍓
Tarlan Isaev 🍓

Posted on

FlutterFlow | Codemagic CI with Google Play Store

**TL:DR :)

Setting up a Flutter project**

Files preparation

Before listing our app on Codemagic we shoul prepare our project for the delivery. Here's my "build.gradle" file with the complete code.

Path: ../android/app/build.gradle

`def localProperties = new Properties()
def localPropertiesFile = rootProject.file('')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the file.")

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'

apply plugin: ''
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: '' // Google Services plugin

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
compileSdkVersion 31
ndkVersion '23.1.7779620'
sourceSets { += 'src/main/kotlin'

lintOptions {
    disable 'InvalidPackage'

defaultConfig {
    // TODO: Specify your own unique Application ID (
    applicationId "com.flutterflow.foodshare"
                minSdkVersion 21
    targetSdkVersion 31
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
               ndk {
                       debugSymbolLevel 'FULL'
signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
        storePassword keystoreProperties['storePassword']

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.release
Enter fullscreen mode Exit fullscreen mode


flutter {
source '../..'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

Acording to our delivering build we have to increase our "version: 1.0.0+1" build in root folder of our project "../pubspec.yaml". The second build is going to be "version: 1.0.0+2" and so on and so forth.

Path: ../pubspec.yaml

version: 1.0.0+13

Version inconsistency between local and Codemagic

First, you need to make sure that the gradlew file isn’t in ".gitignore". Look for "../android/gradlew", and if it’s in ".gitignore", delete it from there. I simply commented two lines. Then add "!gradle-wrapper.jar" to a new line in ".gitignore" to create an exception so that "gradle-wrapper.jar" would also be excluded from ".gitignore".

Path: "../android/.gitignore"





Change "distributionUrl" to version "7.2" in "../android/gradle/wrapper/"

Path: ../android/gradle/wrapper/


In our case, run "./gradlew wrapper --gradle-version 7.2" inside "../android" locally to create gradlew and files in your repository.

Change icons

A bit annoyng part for me is changing icons in a few folders. Otherwise we will see the default flutter icon on installed app. Hopefully it will be fixed soon by FlutterFlow team :)

Following path "../android/app/src/main/res" and directories within it:

  • ../android/app/src/main/res/mipmap-hdpi
  • ../android/app/src/main/res/mipmap-mdpi
  • ../android/app/src/main/res/mipmap-xhdpi
  • ../android/app/src/main/res/mipmap-xxhdpi
  • ../android/app/src/main/res/mipmap-xxxhdpi

Image description

For toasting those icons I've been using online tools. Not sure which platforms in particular. Here's a few anyway :)

Codemagic configuration

Image description

I'll just simply share my configuration to make things way easier 🙂

Build for platforms

  • Android Image description

Run build on

  • Free - macOS Standard VM (2.3GHz Quad Core / 8GB)
  • No "Build triggers"
  • No "Environment variables"
  • No "Dependency caching"

Image description

Add custom settings

  • No "Post-clone script"
  • No "Pre-test script"


  • No tests are covered yet

*Add custom settings for post-tests *

  • No "Post-test script"
  • No "Pre-build script"

In my case I changed a few settings:

  • Flutter version: channel Beta
  • Mode: release

*Add custom settings for post-build scripts *

  • No "Post-build script"


*Enable Android code signing. *
Was covered in Build and release an Android app to Google Play Store.

  • Keystore*: upload keystore
  • Keystore password: add keystore password
  • Key alias: upload
  • Key password: add key password

Enable Google Play publishing

  • Add "Credentials (.json)*" key.

Image description

If you don't have the json key or file is corrupted you should generated it on "Google Cloud Platform" at "IAM & Admin" section and "Service accounts".

Press "Create Service Account". Here's my overview.

Image description

Add the service account name and click "Done".
Image description

Grant this service account access to project:

  • Cloud Build Editor
  • Firebase Service Management Service Agent
  • Service Account Token Creator
  • Service Account User

Finalise it - click "Done".

Image description

Create new or add JSON key in key category. For my project I added a new key.

Image description

Generated and added key should look like this.

Image description

Firebase App Distribution

  • Disabled


  • Enable email publishing and add your email.
  • Slack is disabled.

Post-publish script

  • No any script

Configs in yaml format
Here's the complete config codemagic.yaml file
Track: internal

`# Automatically generated on 2021-11-13 UTC from

Note that this configuration is not an exact match to UI settings. Review and adjust as necessary.

name: Default Workflow
max_build_duration: 30
FCI_KEYSTORE_PATH: /tmp/keystore.keystore
flutter: beta
xcode: latest
cocoapods: default
- |
# set up
echo $FCI_KEYSTORE | base64 --decode > $FCI_KEYSTORE_PATH
cat >> "$FCI_BUILD_DIR/android/" < storePassword=$FCI_KEYSTORE_PASSWORD
- |
# set up local properties
echo "flutter.sdk=$HOME/programs/flutter" > "$FCI_BUILD_DIR/android/"
- flutter packages pub get
- flutter build appbundle --release
- build//outputs/apk//.apk
- build/
- build//outputs//mapping.txt
- flutter_drive.log
credentials: Encrypted(Z0FBQUF...VNUdUMU09)
track: internal
in_app_update_priority: 0`

Last step
Run following "flutter clean" command on terminal and commit the changes then rerun your Codemagic build.

Image description


Error caused by dependencies or could be something else
If you encounter an error with dependencies pls try out to clean your project through the terminal:

sudo flutter clean && sudo rm ios/Podfile && sudo rm ios/Podfile.lock pubspec.lock && sudo rm -rf ios/Pods ios/Runner.xcworkspace && sudo rm -Rf ios/.symlinks && sudo rm -Rf ios/Flutter/Flutter.framework && sudo rm -Rf ios/Flutter/Flutter.podspec


flutter pub get && flutter packages pub run build_runner build --delete-conflicting-outputs

then once again commit the changes and rerun your Codemagic build.

That should help you to set up the CI/CD pipeline :)

Thank you :)

Top comments (0)