I am trying to generate signed apk with an exiting keystore
but i have following problem
Error:org.gradle.tooling.BuildException: Failed to read key MedicalAssistanceKey from store "D:\MedicalAsError:com.android.ide.common.signing.KeytoolException: Failed to read key MedicalAssistanceKey from store
"D:\MedicalAss_download\MyKey.jks": Cannot recover keys_download\MyKey.jks": Cannot recover key
Error:java.security.UnrecoverableKeyException: Cannot recover key
I am sure the password and key are correct
The keystore and key passwords have to be the same.
You could use commands to modify passwork as below:
keytool -storepasswd -new [insert new keystore password] -keystore [insert keystore file name]
keytool -keypasswd -alias [insert alias] -new [insert new key password] -keystore [insert keystore file name]
Or if you like GUI, download from http://keystore-explorer.org/
Note: keytool.exe exists in jdk/bin folder or jre/bin folder.
if you have special characters in your passwords use this tool to change it:
http://keystore-explorer.org/
special characters like Ç
Related
I get the title and the text below when I try and fail to build an .aab file using flutter build appbundle:
java.util.concurrent.ExecutionException: java.lang.RuntimeException: jarsignerfailed with exit code 1 :
jarsigner: Certificate chain not found for: keystore. keystore must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.
I had to reset my signing key. The google developer support had me generate a new .jks file with the following command line which I ran from within my project folder:
keytool -genkeypair -alias upload -keyalg RSA -keysize 2048 -validity 9125 -keystore keystore.jks
He then instructed me to convert this file into a .pem file using this command:
keytool -export -rfc -alias upload -file upload_certificate.pem -keystore keystore.jks
I then emailed him the upload_certificate.pem file. I immediately noticed that the keystore.jks file was red in the sidebar and I get this upon clicking on it:
"The file 'keystore.jks' is not associated with any file type. Please define the association:"
The .pem file is also red, but clicking on it shows the text that makes up the key.
Do I need to reset the signing key again and do something different? Is there a way to fix the issue causing this error?
As dumb as this may sound, I spent 24 hours on this and all I had to was enter flutter clean
You have keyAlias=keystore in your key.properties while it looks like the alias you created is named upload (see in your keytool export command).
Repleace with keyAlias=upload and that should work if your password is correct.
I can't signed my apk with the existing keystore. Its giving me this error when signing:
com.android.ide.common.signing.KeytoolException: Failed to read key Cannot recover key
So, by following this link, I have tried to change the password but its giving me keytool error: java.security.UnrecoverableKeyException: Cannot recover key error when executing this command:
keytool -keypasswd -alias %MyKeyAlias% -new %newpassword% -keystore KeyStore.jks
I have already a version available in playstore using this keystore.
I finally solved it by reading the document:
https://www.rickyadams.com/wp/index.php/2017/11/15/keytool-java-keystore-ssl/
As I use a different storepass and keypass.
Verify the private key password by attempting to change it
> keytool -keypasswd -keystore KEYSTORE -alias ALIAS -storepass PASSWORD
This is the output you’ll see if a key password isn’t set, or if the key password is the same as the store password:
New key password for <ALIAS>:
This is the output you’ll see if a key password is set and you enter it incorrectly:
Enter key password for ALIAS:
keytool error: java.security.UnrecoverableKeyException: Cannot recover key
This is the output you’ll see if a key password is set and you enter it correctly:
Enter key password for <ALIAS>:
New key password for <ALIAS>:
Looks like missing private key.
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.
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:
Don't use space or invisible character in the key alias. as far as possible
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.
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'
}
}
}
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".
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=***
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.
Build -> Rebuild project
It seems old key names are cached.
If you had the .Jks file before then you can get alias name by typing this command
keytool -v -list -keystore .jks
or
keytool -v -list -keystore .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.
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
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.
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.
Do not use capital keys for password. It's worked for me.
For generating .jks keys ,
keytool -genkey -alias myKeyStore -keyalg RSA -keystore "C:\apk\fastmoneyv1.jks"
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
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 :)
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
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
I'm automating some things that involve the android keytool and jarsigner. The tool takes a keystore, the password for the keystore, the alias name, and the password for the alias / key, and I'm trying to find a way to explicitly check to see if the supplied password for the alias / key is correct.
Any ideas? Also, I need to check it without a jar file to sign - getting that file in my context is lengthy, so I want to abort sooner rather than later.
You can also check if the password is correct without attempting to change the password. I did it by listing the properties of the keystore with this command:
keytool -list -keystore <keystorefile> -storepass <passwordtocheck>
You can do it a couple of ways:
A. With keytool
If you run the command keytool -keypasswd -keystore <keystore> -alias <alias> -storepass <storepass> -keypass <keypass> -new <keypass> then you will get the error Keystore was tampered with, or password was incorrect if the keystore password is wrong, or the error Cannot recover key if the alias password is wrong. Unfortunately the return code is 1 in both cases, so you will need to do parsing of the program's output if you want to be smart about the type of error.
B. With a small Java program
Something along these lines:
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
try (FileInputStream fis = new FileInputStream(keystore)) {
ks.load(fis, ksPw.toCharArray());
}
ks.getEntry(alias, new KeyStore.PasswordProtection(aliasPw.toCharArray()));
will fail at line 4 with a java.io.IOException if the key store password is wrong, or with a java.security.UnrecoverableKeyException at line 7 if the alias password is wrong.
recently I added a new alias to my keystore to sign my app.
Now I lost the new generated file with the alias, but remember the password and the alias name and have an older copy the file. Is there a way to recreate the alias using this things?
You can list the contents of your keystore with the command:
keytool -list -keystore <name of keystore file>
To do this, you will need to provide the keystore password (not the alias password). This will tell you the aliases in the file, which are self-contained, allowing you to sign. If you wish, you could also extract keys using other options / tools.
Open your key store (.jks) file with text editor. It will display binary form of data. The readable text in the first line is your key alias.
For example, your key alias in the following binary data is the key alias.
þíþí your key alias UYY_ 0‚þ0
+* ‚êa÷í–ØRö}ðžá䶈ùÎL\ô©2‘wå¥H¨V †¸®Àµ£ð×þ7—â;TÁÙcsª”ž˜4ÝÉ'AÀì,’„×S¼ðßÅ'€Õ¡ó‚˜ ö!y’Çåx|(woÁh4u-û†‚‡§Qȸ|ˆ³”ÜæûZŽ²a±O´¢^À.ªbÅ“e†6 É秮j§˜y ößÿØ0Çd# /Ã?®¦ìé¼/§Zq””Ê•©„=~Ùì¢>º}DàO<Ö¹SbpÎŒ#Ø„°^Í^e»>¾ü«nM(
"Nbûh·2ðÁ0¯ç¿61êè“[.ÇzeYŽºXkuÄy*ôq¥FSs]:2“ì
http://tim12332013.blogspot.tw/2014/10/corona-sdk-android-keystore-lost-alias.html
look it may help you
keytool -list -v -keystore X:/XXXX /XXXX.keystore -storepass XXXX
This worked for me:
keytool -list -v -keystore "file address"
Copy your alias name and TaDa!!!
The default alias in latest android studio version is "key0". You can try this if you haven't changed your alias value.