Flutter Issue | Keystore file not set for signing config release

Viewed 61845

Running the command flutter build appbundle --release or flutter build apk --release I have this issue

Keystore file not set for signing config release

I'd follow the steps of the flutter.dev/docs: https://flutter.dev/docs/deployment/android#configure-signing-in-gradle but still the same.

I create the key.propeties file and replace the content in the build.grade file.

Build.gradle

Key.properties

Also replace de build types with:

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

But still getting the same issue:

  • What went wrong: Execution failed for task ':app:validateSigningRelease'.

Keystore file not set for signing config release

Somebody already solve this issue?

28 Answers

The instructions here did not work for me out of the box. I had to change the key.properties file path to:

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

You can test your configuration is being read properly or not by printing the values to the console. For example, in your gradle file you can have:

println keystorePropertiesFile

to make sure that object is populated with the values you expect

My issue was that I've put the key.properties file in the folder /android/app and it was meant to be in /android/

This one is for windows users. Inside key.properties i was using:

storeFile= C:\users\username\key.jks

instead we need to use:

storeFile= C:/users/username/key.jks

This solved my issue!

The same problem I faced and after doing lots of R&D .... I have done these: First Executed this command:keytool -genkey -v -keystore c:\Users\Ziya\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key

Then in key.properties: Changed the storeFile to this value: C:\\Users\\Ziya\\key.jks

Then Result I got:

flutter build appbundle
Running Gradle task 'bundleRelease'...

Running Gradle task 'bundleRelease'... Done
    5.3s
√ Built build\app\outputs\bundle\release\app-release.aab        
(17.7MB).

You have to Create a file that have key prperties in path like that

[project]/android/key.properties 

And that's File data

storePassword=password
keyPassword=password
keyAlias=upload
storeFile=C:/user/project/upload-keystore.jks

My Problem was that I stored the key.properties file in app folder instead of android folder.

Try removing " from the path mentioned for keystore file

that seems to be the problem.

contents of key.properties files should be like this

storePassword=XXXXXX
keyPassword=XXXXXXXX
keyAlias=key
storeFile=D:/XXXX/XXXXX/key.jks

If you want to build APK files for testing purposes make sure that you use a debug signing configuration in android/app/build.gradle:

buildTypes {
    release {
        signingConfig signingConfigs.debug
    }
}

Create a key.properties file inside the android folder. If you created a key.properties file inside app folder then maybe this error occurs. I also have faced this issue.

My mistake was to insert values instead of variables. Do not change signingConfigs {...} block

Mistake:

signingConfigs {
    release {
        keyAlias keystoreProperties['key']
        keyPassword keystoreProperties['12345678qwerty']
        storeFile keystoreProperties['/Users/Me/key.jks'] ? file(keystoreProperties['/Users/Me/key.jks']) : null
        storePassword keystoreProperties['12345678qwerty']
    }
}

Right code:

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

In my case this was because I have not added key.properties file and not even created my keystore

So what i have done. Creates a new keystore file and added new key.properties file in Folder[ android/ ]

First step is to create new keystore file with this command
For mac/linux

  keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

and for windows

  keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload

Second Step :

Create a new key.properties file and add to
android/key.properties

Make sure to provide password and storeFile like:

storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=upload
storeFile=<location of the key store file, such as /Users/<user name>/upload-keystore.jks>

Reference Official flutter release build doc

Thanks to @Tomas Baran

This worked for me

For windows user :

  1. Place the key.jks file in /<project-directory>/android/app/Users/user_name/
  2. Open key.properties file which must be (created and edited accordingly if not already) in the <project-directory>/android folder.
  3. Now edit the value of the storeFile in key.properties file to /User/user_name/key.jks.

For Linux users :

  1. Do same as instructed above from steps 1 to 2.
  2. Edit the value of the storeFile in key.properties file to User/user_name/key.jks

NOTE: (preceeding / is removed).

That's it it should work for you now !

originally app->build.gradle

buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

just replace the release to debug in signingConfigs.release to signingConfigs.debug. Your problem will be solved

This states the path you stored the key.properties file on your application, keeping it inside the android folder is good since it concerns only the android signing

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


Change this

storePassword=<XXXXX>
keyPassword=<XXXXXX>
keyAlias=key
storeFile=<C:/Users/saint/Desktop/key.jks>

to 

storePassword=XXXXXX
keyPassword=XXXXXXXX
keyAlias=key
storeFile=D:/XXXX/XXXXX/key.jks

Specifically for error Flutter Issue | Keystore file not set for signing config release

It's a simple mistake. Check your key information file name.

I named it with can extra s e.g. keys.properties instead of key.properties

It was two parts that solved this for me:
I had to move the key.properties file from android/app to android.
I also had to change the slash in key.properties from
storeFile=c:\Users\MYNAME\key.jks to
storeFile=c:/Users/MYNAME/key.jks.
That worked to solve the issues for me.

I was able to fix it by the following operation using android studio.

Before fix

Create key.propeties from File> New> File

image before fix

After fix
Create key.propeties from File> New> Resource Bundle

image after fix

In my case, I originally set the path to my key.jks in the key.properties like this:

storeFile=~/key.jks

and it couldn't read it so all I had to do was change it to:

storeFile=Users/tomas/key.jks

My issue was related to how I was storing the CI variables in Gitlab. Turns out if CI Variables are protected, they will not be printed via echo to a file (which is what I was using). Unprotecting the variable fixed my issue (in a private repo) but that should not be done for public projects.

have you change for example the application ID ? and check if the key.prporties file is there

This looks like a error because you don't have a buildTypes{ release{ signingConfig signingConfigs.release} at your build.gradle... I had the same issue and this solution worked for me

I had exactly this error and I solved it by adding the drive name for storeFile, something like:

C:/xxx/xxx/key.jks

Of course, in Windows.

I just solved my problem using like this

storePassword=xxx
keyPassword=xxx
keyAlias=key
storeFile=F:\\xxx\\key.jks

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.release
    }
}

I'm facing same problem. I solve my problem following this step:

Step 1: Put the upload-keystore.jks file in the project folder android/app

enter image description here

Step 2: Set path storeFile= ../app/upload-keystore.jks in key.properties file

Step 3: flutter clean Step 4: flutter pub get Step 5: flutter build apk or flutter build appbundle

My mistake was there was a space after the storeFile path like: storeFile=key.jks .

I just removed it and it worked.

Related