Automatically Signing Flutter Apps with a Keystore
Copy the Key File to the Android Directory:
Place the .jks keystore file in your android directory. For example:
android/key17.jks
Create a keystore.properties File:
Inside the android directory, create a new file named keystore.properties (this name is common, but you can use a different one if desired). In this file, add the following contents:
storePassword=123456 keyPassword=123456 keyAlias=key17 storeFile=../key17.jks
Note: Ensure that the keyAlias matches the alias used when creating the key, and that the passwords are correct.
Add Configuration in build.gradle:
In the android folder, open the build.gradle file and load the keystore.properties file before the android block:
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
Set Up Signing Information in build.gradle:
Add the signing configuration inside the android block, referencing the values from the keystore.properties file:
android {
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
...
}
Rebuild Your App:
Once the configuration is complete, rebuild your app using:
flutter build apk --release