Skip to main content

Build Keystore File and Publish App

πŸ“¦ Manually Packaging the Mazaar Flutter App​

1. πŸ”‘ Generate the Keystore File​

First, navigate to where keytool is located and run the following command to generate a keystore:

keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias MazaarFERelease

Example pathing with command for keytool location:

PS C:\Program Files\Eclipse Adoptium\jdk-21.0.1.12-hotspot\bin> keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias MazaarFERelease

Follow the prompts and provide the necessary details:

  • Keystore password: [Enter a secure password]
  • First and last name: [Firstname Lastname]
  • Organizational unit: Dev
  • Organization: Mazaar
  • City or Locality: Sunnyvale
  • State or Province: CA
  • Country code: US

Once completed, the system will generate a 2048-bit RSA key pair and self-signed certificate valid for 10,000 days, and it will store it in key.jks.

2. πŸ“„ Create key.properties File​

At the root of your android folder in MazaarApp Frontend, create a key.properties file and include the following content:

STORE_PASSWORD=[Your keystore password]
KEY_PASSWORD=[Your key password]
KEY_ALIAS=MazaarFERelease
KEYSTORE_PATH=C:/Program Files/Eclipse Adoptium/jdk-21.0.1.12-hotspot/bin/key.jks

Your KEY_PASSWORD is usually the same as the STORE_PASSWORD password.

3. πŸ› οΈ Update build.gradle​

In your project’s build.gradle file, include the following code before the android section to load the keystore properties:

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

4. πŸ–ŠοΈ Configure Signing in build.gradle​

Update the signingConfigs section in the build.gradle file. If you encounter issues, consider running flutter clean before rebuilding the project.

signingConfigs {
release {
keyAlias keystoreProperties['KEY_ALIAS']
keyPassword keystoreProperties['KEY_PASSWORD']
storeFile file(keystoreProperties['KEYSTORE_PATH'])
storePassword keystoreProperties['STORE_PASSWORD']
}
}

buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.debug
debuggable true
}
}

5. πŸš€ Build the App Bundle​

Run the following command to build the app bundle for release:

flutter build appbundle --flavor prod --release --obfuscate --split-debug-info=build/symbols
note

This command may be out of date; Check the workflow file main.yml to see the latest command

This will also generate the necessary debug symbols for de-obfuscating crash reports.

6. πŸ› οΈ Upload Native Debug Symbols​

To upload native debug symbols, go to:

[YOUR_PROJECT]/build/app/intermediates/merged_native_libs/release/out/lib

Inside this folder, you'll find subdirectories:

  • arm64-v8a
  • armeabi-v7a
  • x86_64

Select these three folders, compress them into a .zip file, and upload it as a symbol file to Firebase Crashlytics.

Note: Do not compress the entire ./lib folder.

7. πŸ“… Versioning for New Releases​

In your pubspec.yaml file, ensure proper versioning for each new release. The version is set as follows:

version: 1.1.0+2
  • 1.1.0: This is the versionName (the semantic version users see).
  • 2: This is the versionCode (increment this integer with each release).

8. πŸ› οΈ Enable Crashlytics (if not already enabled) and De-Obfuscate Crash Reports​

To enable Crashlytics and upload debug symbols, use this Firebase CLI command:

firebase crashlytics:symbols:upload --app=1:477683856186:android:fd23d8bac6b38b50aa9603 build/symbols

To de-obfuscate a stack trace manually if you got it through google play console, use the following command:

flutter symbolize -i <stack-trace-file> -d build/symbols/android-arm64.symbols

By following these steps, you can successfully build, obfuscate, sign, and package your Flutter app for release on Google Play, while maintaining robust crash reporting and version management.