keyAlias=upload
keyPassword=####
storePassword=####
storeFile=../app/upload-keystore.jks
keytool -genkey -v -keystore ./android/app/upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Note
- If
keytool
Not Found, Install Java JDK. - Use The Same Password Used in
key.properties
: #### - The
-storetype JKS
tag is only required for Java 9 or newer. As of the Java 9 release, the keystore type defaults to PKS12.
Tip
To Convert From JKS → PKCS12
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.jks -deststoretype pkcs12
To Convert From PKCS12 → JKS
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.jks -deststoretype jks
- In the menu bar, click Build > Generate Signed Bundle/APK.
- In the Generate Signed Bundle or APK dialog, select Android App Bundle or APK and click Next.
- Below the field for Key store path, click Create new.
- On the New Key Store window, provide the following information for your keystore and key, as shown in figure.
For More Details Check This Out.
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
...
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storePassword keystoreProperties['storePassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
}
}
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
signingConfig signingConfigs.release
}
}
}
Note
You might need to run flutter clean after changing the gradle file. This prevents cached builds from affecting the signing process.