When I try to create signed bundle for my flutter app I get
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
> Failed to read key key0 from store "/Users/username/keystores": keystore password was incorrect
I have the correct password and I know this because I wrote it down. My password has only numbers and basic letters. When I run
./gradlew signingReport
I get
Variant: release
Config: release
Store: /Users/myname/keystores
Alias: key0
Error: Failed to read key key0 from store "/Users/myname/keystores": keystore password was incorrect
This same failure happened when I tried to use the keystore for the first time but then I was able to fix it by cleaning the android project. But now the cleaning does not work anymore.
Here is my app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 31
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "myApplicationId"
minSdkVersion 24
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
shrinkResources false
minifyEnabled false
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Here is my local.properties
sdk.dir=/Users/myName/Library/Android/sdk
flutter.sdk=/users/myName/developer/flutter
flutter.buildMode=release
flutter.versionName=0.1.5
flutter.versionCode=6
I have tried:
- Cleaning and rebuilding the project
- Default passwords ("changeit", "android", "password", "")
- Removing build folder
- Reinstalling Flutter, Dart and Android studio
2
Answers
you point gradle to
key.properties
From this seems like your password is wrong.
If key.properties file is missing it will throw errors.
In the same folder as local.properties, create a key.properties and enter you values.
eg
I had the same issue but what I did was to go to my home location file and delete the upload-keystore.jks file and everything worked fine