Publish Flutter App on Android Store
So, to publish any Android App or Flutter App to Google Play, requires a digital signature. Let’s sign our App using the keytool to build a keystore.
Step 1: Generate KeyStore using KeyTool
On Mac:
keytool -genkey -v -keystore ~/key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
On Windows, use the following command:
keytool -genkey -v -keystore c:/Users/REPLACE_USER_NAME/key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
As a result, it will prompt to confirm the information for Name, Organisation Name, Password, City, State & Country Code. Upon confirming with Y or Yes to generate the Keystore for your Flutter App. Make note of the password submitted above as we will use it in next step.
Step 2: Reference KeyStore in the App
Create a new file named /android/key.properties inside the flutter app root directory, that contains a reference of the above keystore. Add the following content in the file:
storePassword=REPLACE_STORE_PASSWORD
keyPassword=REPLACE_KEY_PASSWORD
keyAlias=key
storeFile=c:/Users/REPLACE_USER_NAME/key.jks
Give the password, alias & keystore path which you had given earlier to generate the keystore.
Step 3: Configure signing in Gradle
Open application level build.gradle file from /android/app/build.gradle and add the following code before android {….} block:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
...
}
And the following code before buildTypes:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Step 4: Versioning & Build App bundle
Review the version in the App in pubspec.yaml file:
version: 1.0.0+1
After saving the version build your app’s APK to finally publish it on Google Play Store. In the terminal window type the following commands:
cd <flutter app root directory path>
flutter build apk
The App release bundle is saved at /build/app/outputs/apk/release/app.apk and we are partially ready to submit flutter app on Google Play.
Step 5: Submit Flutter App on Google Play for Review
Final step is to submit the Flutter App on Google Play. Following the below steps:
- Sign up for or Sign in into the Google Play Console.
- Create a new application and give it a relevant name.
- On the Store Listing page fill up all the mandatory details such as upload icons, screenshots, assign categories and other content ratings.
- On the App releases page, add the flutter app APK release bundle to the production track and give a release name.
- Also make sure to complete all the mandatory fields and sections before you submit your app for review.
- Press the Submit for Review button and wait for Google Play team to revert back with a store listing page.
That’s pretty much it. In case you have any questions to ask, do leave a comment below.