37

Our android project consists of mobile and wear app ( wear app is under development) and we are trying to release the mobile app. When we try to generate signed apk we get this follow message :

Error:Execution failed for task ':wear:packageRelease'.
> com.android.ide.common.signing.KeytoolException: Failed to read key
toyanathpatro from store "/home/adventure/toyanath_patro_key/toyanath_patro_key":
No key with alias 'toyanathpatro' found in keystore /home/adventure/toyanath_patro_key/toyanath_patro_key

As it reads it says failed task for :wear:packageRelease where in reality we are selecting just the mobile while choosing for signing the apk.

Can anyone point out my blunder ? Thanks in advance.

Zeeshan Ali
  • 176
  • 1
  • 5
  • 19
erluxman
  • 18,155
  • 20
  • 92
  • 126

16 Answers16

66

The problem seems to be with the wrongly spelled key alias In my case the alias should have been toyanath patro where I wrongly tried to use toyanathpatro . So the best suggestion would be:

  1. Don't use space or invisible character in the key alias. as far as possible

  2. There is a small selection button (3 horizontal dots) on the right side of key alias editable field. Use that button to find the alias which resides in that signature file.

key alias editable field

Mario Kutlev
  • 4,897
  • 7
  • 44
  • 62
erluxman
  • 18,155
  • 20
  • 92
  • 126
13

In your build.gradle you have defined a signing config that it's pointing to a keystore that it's not in your code base.

Something similar to this.

android {
    ...
    buildTypes {
        release {
            signingConfig signingConfigs.staging
            ...
        }
    }
    signingConfigs {
        defaultSignature {
            keyAlias 'default'
            keyPassword 'password'
            storeFile file('default-keystore.jks')
            storePassword 'password'
        }
    }
}
Xavier Rubio Jansana
  • 6,388
  • 1
  • 27
  • 50
  • Sadly there is not have any ideas what else can cause this ? – erluxman Oct 29 '16 at 08:33
  • You didn't provide any feedback. Did you try what I suggested? Is the error message still the same? Also, please provide your complete build.gradle. – Xavier Rubio Jansana Oct 29 '16 at 10:39
  • I should be really sorry for not being able to respond as i have been in holidays with no internet literally.. As soon as i get my laptop back at home I will surely not forget to try the generous suggestion you have given. – erluxman Nov 07 '16 at 03:17
  • Helped a lot. Was able to figure out that my key's alias was some thing different. Used this to change https://knowledge.digicert.com/solution/SO29304.html – Visakh Vijayan May 16 '20 at 19:24
13

If you had the .Jks file before then you can get alias name by typing this command

keytool -v -list -keystore file.jks

or

keytool -v -list -keystore file.keystore

then you will have to type the password and you will get the alias name by that alias name you can create your signed release file easily.

Filippo Orrù
  • 195
  • 3
  • 8
Sandip
  • 131
  • 1
  • 2
10

In my case android studio by default create alias 'key0' and it is the only alias in the file. My fast solution: Create new key file from android studio with alias that You want. Use that new created file with "Generated Signed APK". If all goes well You could run app with properties set up in "Project Structure".

SkorpEN
  • 2,491
  • 1
  • 22
  • 28
7

After generating keystore with-

keytool -genkeypair -v -keystore my-key.keystore -alias my-alias -keyalg RSA - 
keysize 2048 -validity 10000

You should use exact name of alias in gradle.properties :-

MYAPP_UPLOAD_STORE_FILE=my-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=my-alias <------this name
MYAPP_UPLOAD_STORE_PASSWORD=***
MYAPP_UPLOAD_KEY_PASSWORD=***
Astha Garg
  • 1,022
  • 7
  • 21
Hrishi
  • 1,210
  • 1
  • 13
  • 25
  • That was the reason for me, but instead of changing gradle.properties i changed alias when generating key to -alias uploadkey which is default value for flutter. – Paulius K. Mar 31 '23 at 11:33
5

I had a sticky configuration which I could not get rid of. Even though I had changed the alias in the signing configuration window, it kept giving me the error "Could not find alias" with the original (wrong) alias that I first entered. I searched manually and found a file on path...

[project]/android/app/build/intermediates/signing_config/release/out/signing-config.json

...which contained the original (wrong) alias I first entered. Deleted the file and built/signed the app again. Hope it helps someone.

Darko Maksimovic
  • 1,155
  • 12
  • 14
4

Build -> Rebuild project

It seems old key names are cached.

Chris Fremgen
  • 4,649
  • 1
  • 26
  • 26
2

I initially used key0 for building. It failed with 'Errors while building APK'. Next time, I changed it to 'key1' to work and it worked.

Ank_247shbm
  • 512
  • 7
  • 17
2

My problem was that I lost my keys and when I contacted google for making a new key I made a new one with an alias name that I don't know so to solve this in your root android project cd app and paste this command keytool -v -list -keystore yourkeystore.jks don't forget to replace the yourkeystore.jks with your key you will get output we need only the Alias name copy this alias name and past it in your key.properties file like this

storePassword=YourPassword
keyPassword=YourPassword
keyAlias=AliasNameCopiedFromLastStep
storeFile=KeyStorePath
Karem Mohamed
  • 361
  • 4
  • 11
1

Click Build>Edit library and dependencies .

Then click plus button in signing tab. Key Alias is as same as Alias Key while generating signed apk build.

Rahul Bharadwaj
  • 2,555
  • 2
  • 18
  • 29
0

Do not use capital keys for password. It's worked for me.

Unheilig
  • 16,196
  • 193
  • 68
  • 98
0

For generating .jks keys ,

keytool -genkey -alias myKeyStore -keyalg RSA -keystore "C:\apk\fastmoneyv1.jks"

Md omer arafat
  • 398
  • 7
  • 10
0

If you are use this code when creating key

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

You have to update "keyAlias" property from key.properties

from: keyAlias=key

to: keyAlias=upload

Eray Hamurlu
  • 657
  • 7
  • 9
0

in my case i had my keystore files already generated. I was updating my app and when i generated signed apk, i was creating new key_alias. Instead i choosed existing key alias from my keystore files and it's been resolved :)

nasibeyyubov
  • 1,735
  • 3
  • 11
  • 28
0

in my case i have space on the right of the alias and you don't see that space make sure to hover is with the mouse

0

My issue was that I was using the "my-key-alias" instead of "key0" as the alias name so I had to check to confirm the actual key alias name keytool -v -list -keystore yourkeystore.jks and changing MYAPP_UPLOAD_KEY_ALIAS=key0 in the app/gradle.properties file instead of MYAPP_UPLOAD_KEY_ALIAS=my-key-alias

yaxx
  • 529
  • 1
  • 6
  • 22