Flutter Picking Wrong Keystore path and giving error key.jks not found

Viewed 30918

I followed all the steps on the Flutter official site and thought I'd done everything correctly but it is failing to locate the keystore file when I build it.

This is the error message I get showing it taking wrong path instead of D:\flutterapps\testapp\key.jks:

PS D:\flutterapps\testapp> flutter build apk
Initializing gradle...                                       1.3s
Resolving dependencies...                                    4.3s
Gradle task 'assembleRelease'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\flutterapps\testapp\android\app\ D: lutterappspublishkey.jks' not found for signing config 'release'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Gradle task 'assembleRelease'... Done                        5.3s
Gradle task assembleRelease failed with exit code 1
PS D:\flutterapps\testapp>
5 Answers

On Windows you have to use 2 backslashes to indicate the path separation. In your key.properties, you should have something like this:

storeFile=D:\\flutterapps\\testapp\\key.jks

You don't need to copy your key.jks file to your flutter project.

modified key.properties file with

storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=key.jks

instead of this

storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=D:\flutterapps\testapp\key.jks

and also moved key.jks to D:\flutterapps\testapp\android\app\key.jks

as this path shown in error inside terminal

Thanks all.

it's wherever call it from in your build.gradle. insert this:

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

and call this in above your android{}:

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

and that key.properties file (which should be in your root android folder) should have this:

storePassword=12345
keyPassword=12345
keyAlias=key
storeFile=/Users/me/somekey.jks

Yeah, for me... I forgot to change my signingConfig to singingConfigs.release in my build.gradle file.

    buildTypes {
        release {
           //CHANGE THIS TO RELEASE
            signingConfig signingConfigs.debug
        }
    }

In build.gradle

Replace

def keystorePropertiesFile = rootProject.file('key.properties')

to

def keystorePropertiesFile = rootProject.file('app/key.properties')
Related