In this article, I will be showing how to add Flutter to your new or existing Native Androidproject and how to test it on Codemagic CI/CD using codemagic.yaml file.

The YAML feature is currently in beta and has the following limitations:

  • Exporting configuration from UI is supported for Flutter-based Android, iOS and web apps.
  • The exported configuration is not identical to the settings in UI and lacks the configuration for some features, such as Stop build if tests fail and publishing to Codemagic Static Pages.

I will be starting from the scratch to give you some tips and tricks in the way. So, let us first create a simple Native Android app for this tutorial.

Editor’s Note: We also recommend you to read iOS Code Signing and Publishing with codemagic.yaml file.

App Overview

App screensApp screens

We will be creating a simple app called Court Counter, which will be a score keeper for a basketball match between two teams.

It will contain two screens:

  1. Splash screen (using Flutter Module)
  2. Counter screen (using Native Android)

Creating a native Android app

  1. Start Android Studio on your system.
  2. Click on Start a new Android Studio projectAndroid Studio
  3. Choose Empty Activity and click on NextChoose your project
  4. Now enter the details for the project.
  • Name: CourtCounter
  • Package name: com.example.courtcounter (auto-filled)
  • Save location: ~/Desktop/CourtCounterFlutter/CourtCounter

Project detailsProject details

I have added an extra folder to store the native Android project because this will make it easier to add the Flutter module later.

  1. Click on Finish and wait for the initial Gradle sync to complete.

So, the empty native Android project is ready.

Creating Flutter module

The Flutter module should be added as a sibling to the native Android project. Assuming that you have your Android project at path/to/project/nativeApp, where nativeApp is the name of your Android project folder, then you have to create the Flutter module from path/to/project folder.

The steps for creating the Flutter module are as follows:

  1. Go to the Terminal inside your Android Studio IDE.
  2. You will be inside your Android project folder, but we have to add the Flutter module as a sibling to the native app. So, you have to go to the previous folder and use the following command to create a new Flutter module.
$ cd ..

$ flutter create -t module name_of_module

Android Studio

#android #flutter

How to add Flutter modules to native Android project and test it on Codemagic
4.05 GEEK