Setup - Building Android App Bundle

Step 12: Building the Android App Bundle for Publishing

To publish your app on the Google Play Store, you need to generate a signed Android App Bundle (AAB) or APK. Follow these steps.

A. Verify google-services.json

Ensure that the Firebase configuration file is present:

B. Generate a Keystore for Signing

Run the following command to generate a signing key:

keytool -genkeypair -v -keystore release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias your_key_alias

Follow the prompts to enter the keystore password, alias name, and other details.

Keystore Generation
C. Move the Keystore File

Move the generated release-key.jks file into the android/app/ directory.

D. Create keystore.properties File

Create a file named keystore.properties inside the android/ directory with the following content:

storeFile=release-key.jks storePassword=your_store_password keyAlias=your_key_alias keyPassword=your_key_password
Keystore Properties File
E. Update build.gradle for Signing

Modify the android/app/build.gradle file by adding the signing configuration:

android { ... signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } }
F. Build the Release APK or AAB

Run the following command to generate the build:

For APK:

flutter build apk --release

For App Bundle (recommended for Play Store):

flutter build appbundle
G. Locate the Generated Files

Once built, the output files will be in:

These files are ready for upload to the Google Play Store.