Publishing an Android Application with Flutter to the Google Play Store
1. Adding a launcher icon
I have already explained how to change the app’s icon in this story.
2. Signing the app
- Create an upload keystore
If you have an existing keystore, skip to the next step. If not, use the following command to generate a key;
keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
After write your directory instead of USER_NAME, run this command. It will ask for few details such as the key password, store password. After all them, key.jks will be created in the location mentioned above.
3. Reference the keystore from the app
Create a file named key.properties in the android directory of your app(<app dir>/android/key.properties
) and paste the below lines.
Drag and drop upload-keystore.jks file to app dir/android/app path directory.
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=upload
storeFile=<location of the key store file>
Fill above without using ‘< >’ such as storeFile=../app/upload-keystore.jks .
4. Configure signing in gradle
- Add the keystore information from your properties file before the
android
block:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}android {
...
}
- And add code before
buildTypes
block:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Don’t forget to change signingConfigs.debug to signingConfigs.release.
5. Building an app bundle
After run flutter clean
, run flutter build appbundle
in terminal.
Now, we are ready for publishing app to the Google Play Store! 🎉
Thanks for reading!