failed for task :app:signReleaseBundle'A failure executing com.android.build.gradle.internal.tasks.Workers$ActionFacade, Failed to read key from store

Viewed 2513

When I build a release .abb flutter app I face a problem, I spent more than 2 weeks looking for a solution for this problem but none of those solutions worked, so I hopefully ask you to help me.

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Failed to read key final.jks from store "D:\keys\final.jks": No key with alias 'final.jks' found in keystore D:\keys\final.jks

The solutions I've tried:

  1. I've made sure of the keystore file directory and password <I also put the password without "">.
  2. Generated the keystore again to make sure of its password.
  3. I Ran flutter clean after every change in build.gradle
  4. Changed classpath 'com.android.tools.build:gradle:4.1.0' to classpath 'com.android.tools.build:gradle:3.5.0'
  5. Changed the keystore file path from C: to D:
  6. Changed the path of key.properties file from /android/app to /android
  7. Deleted the main .gradle file in C: driver and downloaded it again through Android Studio
  8. Finally I tried to build apk but the same problem appears.

This is /android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And this is /android/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 30

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.counter"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }

}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

key.properties file:

storePassword=123456
keyPassword=123456
keyAlias=final.jks
storeFile=D:/keys/final.jks

My Android studio version is "Arctic Fox 2020.3.1" and the flutter SDK version is 2.5

This is my first app so I hope you can help me, THANK YOU!

1 Answers

Step 1

Place your final.jks file inside /android/app folder

Step 2

key.properties

storePassword=123456
keyPassword=123456
keyAlias=final
storeFile=final.jks
Related