How to Release Your Flutter Application for Android

How to Release Your Flutter Application for Android

Prerequisites

  • Make sure you have an Android app ready to go.
  • Create a launcher icon and gather all of your app’s assets.

Prepare for release

A digital signature is required before your Flutter app can be published on Google Play.

Create a keystore if you don’t already have one.

On Mac, use the following command:

keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

On Windows, use the following command:

keytool -genkey -v -keystore c:/Users/USER_NAME/key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key

Create a file named /android/key.properties that will reference your keystore, it will look like this:

storePassword= keyPassword= keyAlias=key
storeFile=/key.jks>

Configure signing in Gradle

You will find your Gradle file at /android/app/build.gradle. Start editing and follow these steps:

Replace

With the keystore information that we just created:

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

android {
content_copy
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.debug
}
}

With the signing configuration info:

content_copy
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}

  • Then, go to the defaultConfig block.
  • Enter a final unique applicationId.
  • Give your app a versionName and versionCode.
  • Specify the minimum SDK API level that the app needs to run.

Your app’s Gradle file is now configured, and your release builds will be signed automatically.

Examine the app manifest to ensure that everything is in working order.

The file AndroidManifest.xml will be located in /android/app/src/main. Open it and review the values and permissions you need before building.

Build and release the app

Now you’ll create the APK for your program, which will be posted to the Google Play Store. To get started, go to your command prompt and type the following commands:

  1. Enter cd
  2. Run flutter build apk

If everything goes well, you will have an APK ready at /build/app/outputs/apk/release/app.apk

Publish to the Google Play Store

Your app is ready! Next, follow How to Submit your Android Application to Google Play

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *