Hi Everyone,
Every time when you finish your development and try to build the app bundle, always face some errors. For that, I have come up with this idea to show you how quickly we can men this barrier. Let's see the steps:
First Step: Adding a launcher icon
You can easily do this by following the package Flutter_launcher_icon. It is necessary to publish your app. Otherwise you may get rejection message.
Second Step: Signing the app
To sign the app, we need to upload a key store, which represents the secret key for signing the app. There are two steps. One is Android Studio Key Generation App, and the other is running a code on your PC. As I am a windows user, I will show you the windows process, Linux/MAC user's process is almost similar. You need to have JAVA installed on your PC. As my Java folder is created in your drive, mine is in C drive, go to the jre/bin dir, and I need to paste the following code in the command prompt:
C:/Program Files (x86)/Java/jre1.8.0_351/bin/cmd.exe
keytool -genkey -v -keystore D:\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
The keystone file will create in the C: drive. You can choose your own location.
Third Step: Reference the Keystore from the app
Create a file named [project]/android/key.properties, this file contains the keystone reference
Paste the below code in key.properties
storePassword=[your password]
keyPassword=[your password]
keyAlias=upload
storeFile=D:/upload-keystore.jks
Forth Step: Configure signing in gradle
Configure gradle to use your upload key when building your app in release mode by editing the below directory file.
[project]/android/app/build.gradle file.
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 {
...
}
Load the key.properties file into the keystoreProperties object. Find the buildTypes block:
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now,
// so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
And replace it with the following signing configuration info:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
That's it. Now run the below command to build the app bundle for the Google play store.
flutter build apk
or
flutter build appbundle
Hope this might help in your development journey.
Read More: Know about the Flutter Column and Row