Publishing your Flutter app to the Google Play Store might seem intimidating, but the process is actually quite straightforward! As a Flutter developer aiming to create an Android app for widespread use, understanding how to publish your Flutter application on the Google Play Store is crucial. In just a few steps, you can make your app available for download to millions of Android users worldwide.
This tutorial is divided into two parts. The first part provides a step-by-step guide on preparing your app for production release. The second part explains the process of publishing your production-ready app on the Google Play Store. If you're already familiar with preparing your app for production release and are eager to learn about publishing on the Google Play Store, you can skip ahead to Part 2 of this series.
Step 1: Change the App Name
- Navigate to the folder:
android/app/src/main/AndroidManifest.xml
- Find the
android:label
attribute and change its value to the desired name for your app.
Tip: You can also add necessary permissions required by your app. For instance, to grant internet access, add:
<uses-permission android:name="android.permission.INTERNET" />
Step 2: Change the App Icon:
In your
pubspec.yaml
file, add theflutter_launcher_icons
package to yourdev_dependencies
Add the following options below
dev_dependencies
flutter_icons:
android: true
ios: true
image_path: "assets/icon/icon.png"
image_path
refers to the path where your app icon is located.
- Run this command to generate your app icons:
flutter pub run flutter_launcher_icons:main
- Now run your app to see the changes.
Step 3: Add a Splash Screen
A splash screen, also known as a launch screen, start screen, or boot screen, is a graphical control element containing the image, logo, and current software version. It's the first screen of the app that displays while the application is loading. For a detailed tutorial on creating a splash screen for your Flutter app, you can refer to this resource.
Step 4: Sign the App
- Create a
keystore
A
keystore
is the unique signature used for signing your app.
- Open your
terminal
and paste the following commands:
On Mac/Linux:
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
On Windows:
keytool -genkey -v -keystore %userprofile%\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
In case you encounter the error:
Operation couldn't be completed. Unable to locate Java Runtime.
Run flutter doctor -v
and copy the path after Java binary at
. Replace java
with keytool
in the command [add \
for Mac and "
for Windows, and remove any spaces]. You should have something like this:
/Applications/Android\ Studio.app/Contents/jbr/Contents/Home/bin/keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Your
keystore
has been successfully created, and the file path is displayed in theterminal
.Create a
key.properties
file in theandroid
folder.Add the following lines of code:
storePassword=<password from keystore file>
keyPassword=<password from keystore file>
keyAlias=upload
storeFile=<location of the keystore file, e.g., /Users/<user name>/upload-keystore.jks>
Make sure to keep them private. Avoid sharing them on public source control platforms.
- Open
android/app/build.gradle
and paste the following lines above theandroid {…}
block:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
- Scroll down and replace the existing
buildType {…}
block with:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
- In the
defaultConfig {…}
section, change the value ofapplicationId
to your preferredId
for your app. This uniqueId
is used to identify your app on the Google Play Store. For example:
applicationId "com.example.my_android_app"
Step 5: Create an Android App Bundle
Run
flutter clean
to clear the cache and previous builds.To generate your
.aab
bundle, run the following command:
flutter build appbundle
The
.aab
build for your app is now located atbuild/app/outputs/bundle/release/app-release.aab
Your app is now ready for publication via the Developer Console.
In this tutorial, you've learned how to prepare a Flutter app for production release. Now, you can publish your app to the Google Play Store in Part 2 of this series.
Top comments (0)