Publishing Flutter app to Google Play Store - Part 1
Tags: flutter, dart, android
Published: 2023-01-28 15:17:19

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](https://dev.to/pozadkey/publishing-flutter-app-to-google-play-store-part-2-nkh)_** of this series.

_**Let’s get started!**_
![Drum roll](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/971xixwikcl6a3a81ge2.gif)

### 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`**

```yaml
flutter_icons:
    android: true
    ios: true
    image_path: "assets/icon/icon.png"
```
> _**`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 
```

- 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](https://www.geeksforgeeks.org/splash-screen-in-flutter/amp/)_**, 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
```

**On Windows:**

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

> _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
```


>

- 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>
```

> _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))
}
```

- 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
     }
 }
```

- 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"
```

### 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
```

- 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](https://dev.to/pozadkey/publishing-flutter-app-to-google-play-store-part-2-nkh)**_ of this series.