Publishing a Flutter App on Play Store
To Publish app on Google Play Store , one need to have a Play Console account. Google charges a nominal fee to open a Play Console account. Go to the official website to signup for account.
After your app is ready , functional and you have tested the app and you want to publish it so that billion of users can access the app . Before releasing the app on play store we need to follow some steps
First of all the app should have a launcher icon that a user sees on a home screen. We can use a package flutter_launcher_icons
Add this package to the dependency in the pubspec.yaml file.
Add code below snippet in the same file. Image path is the path to your launcher icon.
flutter_icons:android: trueios: trueimage_path: "asset/launcher.png"
Run command in VS code/Android studio terminal to generate icons
flutter pub run flutter_launcher_icons:main
Now if install your app you will that the app has a new icon that you have just set.
Now as the icon is changed , We also need to change the name of the app.
For changing the name you need to move to the AndroidManifest.xml file in the following directory.
android -> app -> src -> main -> AndroidManifest.xml
To change the name of the application change the label name in the application Tag
Change the package name from com.example to com. yourdomainName
Add internet permission and other permissions after package name if you need it in production.
<uses-permission android:name="android.permission.INTERNET"/>
Hint- change all the occurances of com.example to com.yourdomainname
Next we need to generate a key
We need a key so that no one can tamper our app and key helps in preventing it. It works as public key cryptography and only you know the private key and hence only you can sign the app.
To Generate key use the following.
The highlighted part is the directory where you are storing the key store file.(Change accordingly) and here I have used upload as alias name
keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
(change the highlighted path to where you want to store keys;
Now to reference this file in the application make key.properties file in android folder
storePassword=password (use the pass that you set in the prev step)keyPassword=password(use the pass that you set in the prev step)keyAlias=uploadstoreFile=c:/Users/USER_NAME/upload-keystore.jks(loc of file)
Go to android -> app ->build.gradle and add following before android block
def keystoreProperties = new Properties()def keystorePropertiesFile = rootProject.file('key.properties')if (keystorePropertiesFile.exists()) {keystoreProperties.load(new FileInputStream(keystorePropertiesFile))}
Replace buildtype section with following code
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Now everything is set and now you just need to build the apk file.
To build apk run
flutter build apk
If using any package that doesn't support null safety
flutter build apk --no-sound-null-safety
Now you can see the apk in the output folder.
\build\app\outputs\flutter-apk\app-relase.apk
To make AAB — App bundle run-:
flutter build appbundle --no-sound-null-safety
After the APK is made now we just need to upload it on the play store so that everyone can access it.
Create a play console account if you don't have it.
I am doing the minimum steps that one need to follow to publish the app.
After logging in , Click on create App.
Fill the names and details as per your app and click on create app.
After creating this app go to dashboard of the app you have created and find below option
Google Play console will ask some questions about the app , answer all the questions.
After answering the questions you will be required to upload the screenshots and icon of the app. Complete that step .
After uploading all the required images you will need to upload the AAB file .
Once you upload the binary , Google play will make your app live in 1–2 days.
Congratulations you have published your app on play store. Share it within your network.