Generate Signed App Bundle for android
2 min readDec 24, 2023
1.Create an upload keystore
1.Command Line:
For Mac:
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA \ -keysize 2048 -validity 10000 -alias upload
In above upload is alias name this will be your path /upload-keystore.jks
For Windows:
keytool -genkey -v -keystore %userprofile%\upload-keystore.jks ^ -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 ^ -alias upload
2. Android Studio through create :
1.Click on Build > Generate Signed/APK
2.Dialog appears
Select Android App Bundle and click on Next
3.On Key store path click Create new.
4.Fill required fields
Click Next
Select release and Click on Create
2.Reference the keystore from the app
Create a file named [project]/android/key.properties
Code in key.properties:
storePassword=<password-from-previous-step>
keyPassword=<password-from-previous-step>
keyAlias=upload
storeFile=<keystore-file-location>
Configure signing in gradle
Open [project]/android/app/build.gradle
Add following code in gradle:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
Now run command in terminal : flutter build appbundle
You will get your output in:
build/app/outputs/bundle/release/app-release.aab (17.6MB).