Setting up your Flutter app for publishing in Play Store.
Before publishing our Flutter app in Google Play Store we need to brush up few feature to make sure that the app is entirely done and eligible for release.🚀 In this article we shall be discussing those features that we need to focus before publishing the app.
App Launcher Icon
Once the functionality and the UI/UX part is done. we need to set up an icon for our app. Setting up a decent good looking app icon is very important.
In the below mentioned article we have already discussed step by step procedure about setting up a launcher icons for flutter app 👇:
https://medium.com/@_Vijay_/change-app-launcher-icons-flutter-b6e4c93b1a39 (both written and video tutorial is available).
Signing the app
After finishing setting up an icon, we need to create a digital signature for our app. This signature is then used for accessing our app for publishing further versions.
- Creating a keystore
For Mac/Linux use the following command to generate a key.,
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
For Windows use the following command to generate a key.,
keytool -genkey -v -keystore c:\Users\USER_NAME\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key
Once you run the above command, It will ask for few details such as the key password, store password and few others.
Once it is done a file named key.jks
will be created in the location mentioned above. In our case it is… c:\Users\USER_NAME
Store this key file (key.jks
) in a secure place because the same key file will be used for signing the app in play store during further release updates.
_____________________________________________________________
- Reference to KeyStore
Create a file named key.properties
in the android directory of your app.
This file must contain the reference to the keystore generated in the previous step.
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=key
storeFile=<location of the key store file, such as /Users/<user name>/key.jks>
Replace the storePassword
, keyPassword
, storeFile
with the desired password and file location provided during the above process.
Setting up Gradle
Change the build.gradle
file available in android/app/build.gradle
with the following keystore information.
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}android {
...
}
Add the above bold text before the android block in your build.gradle
file.
_____________________________________________________________
Similarly add the following code before the buildTypes block in your build.gradle
file.
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Note: Don’t forget to change the signingConfigs
as release
in buildTypes block.
Reviewing the appId and VerionNo
We have now almost completed setting up ✨ our app for release. Now it’s time to check the app id (app name) and the version number before proceeding further.
The below article guides you how to change the app name and version number in detail 👇:
https://medium.com/@_Vijay_/changing-app-name-and-version-number-in-flutter-5eb5cd8ed2f3
Building the app for release
For publishing the app in Play Store, it is preferred to generate app bundle
instead of generating apk files
.
- Generating app bundle.
Run the following command for generating an app bundle
.
flutter build appbundle
The generated app bundle
will be available in the following location.,<app dir>/build/app/outputs/bundle/release/app.aab
.
_____________________________________________________________
We can also generate the apk files
by running the below command.
flutter build apk --split-per-abi
The above command will result in three separate apk’s and they will be available at the below locations as follows.
<app dir>/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
<app dir>/build/app/outputs/apk/release/app-arm64-v8a-release.apk
<app dir>/build/app/outputs/apk/release/app-x86_64-release.apk
_____________________________________________________________
And that’s it from the coding side. 👩💻
💡 Suggestion:
Before uploading your app bundle
or apk
in play store I recommend you to test the app by generating an apk
and run it in a physical device. Just to make sure that the app runs smoothly as expected. Because debug
is different from release
. We may not have encountered few error as we might be running our app in debug
mode.
You can also skip this step if you are confident enough about your code.
For generating an apk use the command.,
flutter build apk
now install this apk
in a physical device and check for the functionality, UI stuffs.
_____________________________________________________________
🚀 Now the app is completely ready for release. Hope you find this article useful.
Other articles you may like.,
🟡 Change App Launcher Icon in Flutter
🔴 AnimatedContainer Widget in Flutter
Flutter Tutorials
If you want to know more about Flutter and various Widgets in Flutter…?🤓 Then visit my channel vijaycreations🚩
Thanks.,