Publish App on PlayStore

1. Prepare Your Flutter App for Release

First, you need to prepare your Flutter app for production by creating a release version.

a. Switch to Release Mode

By default, Flutter runs in debug mode. For the Play Store, you need a release build:

bashCopy codeflutter build apk --release

This generates a release APK file, which can be found at build/app/outputs/flutter-apk/app-release.apk.

b. Optimize Your App

To ensure your app is optimized for release:

  • Minimize your app's size by enabling Dart code obfuscation (optional).

  • Enable ProGuard to remove unused code by adding this to your android/app/build.gradle file:

gradleCopy codeandroid {
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

c. Generate an App Bundle (Recommended)

Google Play encourages developers to upload an Android App Bundle (.aab) instead of APKs. The app bundle allows Google Play to optimize the APKs for different devices.

bashCopy codeflutter build appbundle --release

This will generate an .aab file in build/app/outputs/bundle/release/app-release.aab.

2. Set Up Your App's Icon and Splash Screen

Ensure that your app has a custom launcher icon and a splash screen (optional but recommended) before publishing.

  • To set the app icon, configure it in android/app/src/main/res/mipmap-*.

  • To create a splash screen, update android/app/src/main/res/drawable/launch_background.xml.

3. Configure Your Android Project

Set the Version Code and Version Name

In android/app/build.gradle, update the versionCode and versionName to the correct version for your app:

gradleCopy codedefaultConfig {
    versionCode 1 // Increment this for each update
    versionName "1.0" // Update this as per your versioning scheme
}

4. Sign Your App

Google Play requires that your app be digitally signed before you can upload it.

a. Generate a Signing Key

In your terminal, run the following command to generate a keystore file. This key will be used to sign your app:

bashCopy codekeytool -genkey -v -keystore ~/yourapp-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias yourapp-key

You will be prompted to enter a password and provide some details for your key. Store the .jks file in a safe location.

b. Reference the Key in Gradle

Add the key information to android/key.properties:

propertiesCopy codestorePassword=your_password
keyPassword=your_password
keyAlias=yourapp-key
storeFile=path/to/your/yourapp-release-key.jks

Then modify android/app/build.gradle to use this key for signing:

gradleCopy codeandroid {
    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

5. Test the Release Version

Before uploading, make sure you test the release version of your app on a physical device:

bashCopy codeflutter install

Ensure that everything works as expected.

6. Create a Google Play Developer Account

If you don't already have a Google Play Developer account, you'll need to create one. Go to the Google Play Console and sign up.

  • The registration fee is $25, which is a one-time payment.

  • Fill out the required account details.

7. Create a New Application

Once your developer account is set up, follow these steps:

  1. Go to the Google Play Console and select Create App.

  2. Choose the app's default language, name, and whether it's a game or an app.

  3. Set up your app’s details, including the App Icon, Description, and Screenshots (which you’ll need to prepare in advance).

8. Upload the App Bundle or APK

On the Google Play Console:

  1. Navigate to the "Release" section.

  2. Click on "Production" and then "Create a new release".

  3. Upload the app-release.aab or app-release.apk file you generated earlier.

  4. Fill out any required information, such as the version details and release notes.

9. Set Up Store Listing

Fill in the store listing for your app:

  • App Title: The name of your app.

  • Short Description: A one-sentence description of your app.

  • Full Description: A detailed description of your app.

  • Screenshots: Provide images showing your app’s features. You’ll need at least 2-8 screenshots for phones and tablets.

  • App Icon: Upload a 512x512px app icon.

10. Set Content Rating and Permissions

In the Google Play Console:

  • Complete the Content Rating questionnaire to help classify your app’s age appropriateness.

  • Declare the permissions your app uses (like access to location, camera, etc.).

11. Set Pricing and Distribution

  • Decide whether your app will be Free or Paid.

  • Choose the countries where you want to distribute your app.

  • If your app targets specific devices (e.g., only tablets), configure those settings.

12. Submit Your App for Review

  • Once everything is filled out, click on "Submit" for review.

  • The Google Play review process can take anywhere from a few hours to several days.

After the review process, if everything is approved, your app will be available on the Play Store for users to download.

Last updated