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

1,573

Step 1

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

Step 2

key.properties

storePassword=123456
keyPassword=123456
keyAlias=final
storeFile=final.jks
Share:
1,573
Mo.kh
Author by

Mo.kh

Updated on January 01, 2023

Comments

  • Mo.kh
    Mo.kh over 1 year

    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!

    • Jessé Lopes Pereira
      Jessé Lopes Pereira over 2 years
      Hello, please remove the content from "storeFile", leave it blank. Then run "flutter clean && flutter pub get" and then run "flutter build appbundle"
    • Mo.kh
      Mo.kh over 2 years
      Jessé Lopes Pereira, Thanks for your reply but I still get the error
    • Priyansu Choudhury
      Priyansu Choudhury over 2 years
      The error says that the alias name is wrong, what you can do is open the android folder inside the android studio and select generate signed apk in tools. This will eliminate the problem of naming the alias yourself and all you have to do is give the Keystore password and it will detect the alias name automatically and sign the app for you.
  • Priyansu Choudhury
    Priyansu Choudhury over 2 years
    Make sure while creating Keystore you give Alias name as final
  • Mo.kh
    Mo.kh over 2 years
    Priyansu Choudhury, I appreciate your reply but unfortunately I'm still getting the same error, thank you