DEV Community

Damilare Ajakaiye
Damilare Ajakaiye

Posted on • Edited on

Publishing Flutter app to Google Play Store - Part 1

Publishing your Flutter app to the Google Play Store might seem intimidating, but the process is actually quite straightforward! As a Flutter developer aiming to create an Android app for widespread use, understanding how to publish your Flutter application on the Google Play Store is crucial. In just a few steps, you can make your app available for download to millions of Android users worldwide.

This tutorial is divided into two parts. The first part provides a step-by-step guide on preparing your app for production release. The second part explains the process of publishing your production-ready app on the Google Play Store. If you're already familiar with preparing your app for production release and are eager to learn about publishing on the Google Play Store, you can skip ahead to Part 2 of this series.

Let’s get started!
Drum roll

Step 1: Change the App Name

  • Navigate to the folder:

android/app/src/main/AndroidManifest.xml

  • Find the android:label attribute and change its value to the desired name for your app.

Tip: You can also add necessary permissions required by your app. For instance, to grant internet access, add:

<uses-permission android:name="android.permission.INTERNET" />

Step 2: Change the App Icon:

  • In your pubspec.yaml file, add the flutter_launcher_icons package to your dev_dependencies

  • Add the following options below dev_dependencies

flutter_icons:
    android: true
    ios: true
    image_path: "assets/icon/icon.png"
Enter fullscreen mode Exit fullscreen mode

image_path refers to the path where your app icon is located.

  • Run this command to generate your app icons:
flutter pub run flutter_launcher_icons:main 
Enter fullscreen mode Exit fullscreen mode
  • Now run your app to see the changes.

Step 3: Add a Splash Screen

A splash screen, also known as a launch screen, start screen, or boot screen, is a graphical control element containing the image, logo, and current software version. It's the first screen of the app that displays while the application is loading. For a detailed tutorial on creating a splash screen for your Flutter app, you can refer to this resource.

Step 4: Sign the App

  • Create a keystore

A keystore is the unique signature used for signing your app.

  • Open your terminal and paste the following commands:

On Mac/Linux:

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Enter fullscreen mode Exit fullscreen mode

On Windows:

keytool -genkey -v -keystore %userprofile%\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Enter fullscreen mode Exit fullscreen mode

In case you encounter the error:
Operation couldn't be completed. Unable to locate Java Runtime.

Run flutter doctor -v and copy the path after Java binary at. Replace java with keytool in the command [add \ for Mac and " for Windows, and remove any spaces]. You should have something like this:

/Applications/Android\ Studio.app/Contents/jbr/Contents/Home/bin/keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Enter fullscreen mode Exit fullscreen mode
  • Your keystore has been successfully created, and the file path is displayed in the terminal.

  • Create a key.properties file in the android folder.

  • Add the following lines of code:

storePassword=<password from keystore file>
keyPassword=<password from keystore file>
keyAlias=upload
storeFile=<location of the keystore file, e.g., /Users/<user name>/upload-keystore.jks>
Enter fullscreen mode Exit fullscreen mode

Make sure to keep them private. Avoid sharing them on public source control platforms.

  • Open android/app/build.gradle and paste the following lines above the android {…} block:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
  keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
Enter fullscreen mode Exit fullscreen mode
  • Scroll down and replace the existing buildType {…} block with:
signingConfigs {
     release {
         keyAlias keystoreProperties['keyAlias']
         keyPassword keystoreProperties['keyPassword']
         storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
         storePassword keystoreProperties['storePassword']
     }
 }
 buildTypes {
     release {
         signingConfig signingConfigs.release
     }
 }
Enter fullscreen mode Exit fullscreen mode
  • In the defaultConfig {…} section, change the value of applicationId to your preferred Id for your app. This unique Id is used to identify your app on the Google Play Store. For example:
applicationId "com.example.my_android_app"
Enter fullscreen mode Exit fullscreen mode

Step 5: Create an Android App Bundle

  • Run flutter clean to clear the cache and previous builds.

  • To generate your .aab bundle, run the following command:

flutter build appbundle
Enter fullscreen mode Exit fullscreen mode
  • The .aab build for your app is now located at build/app/outputs/bundle/release/app-release.aab

  • Your app is now ready for publication via the Developer Console.

In this tutorial, you've learned how to prepare a Flutter app for production release. Now, you can publish your app to the Google Play Store in Part 2 of this series.

Top comments (0)