Android keystore password change
Asked Answered
E

6

43

I would like to change the password I use in my keystore for an android app that is already available in google play and I would like to know some things before I do it:

1) If I change the keystore password, could I continue using the same keystore for my uploaded app without any issue (I need to do this, this is why I ask)

2) Does changing my alias password has the same consequences?

3) How should I use keytool?

Entire answered 5/2, 2015 at 12:8 Comment(0)
S
52

If you are using the same keystore for signing your application before pushing it to the play store, it should be fine.
Changing Keystore's password or alias password doesn't affect the way it is used to generate the signed apk.

In order to update the password using keytool:

  1. Open cmd prompt
  2. Browse to the location of the keytool / set the location of keytool in the path variable under the system variables and directly go to step 3
  3. Run the following command:
    keytool -keypass "previous password" -new "new password" -keystore "keystore location"

Security Note
As mentioned in vlz's comment below.
You should not include your password in the command because it'll be written to your command history (~/.bash_history).
Instead, you can use the below command (safely prompt for a password):
keytool -storepasswd -keystore "keystore location"

Recovery plan
Make sure to backup your keystore file first.

Supplicatory answered 5/2, 2015 at 12:44 Comment(12)
Just another little thing if you know, I'm also try to change my alias password but it won't let me (maybe because I'm using a # on it i don't know): does it affect if I create a new alias with new password and use it instead? Maybe it is because my alias has a dot on it?Entire
I am not sure about the reason about why it's not letting you change the password for the allias. But don't change the alias for sure. This will generate a different apk. For details regarding the same, you may refer to this answerSupplicatory
Well, it turns out that I don't know how to read and before asking me for the alias password I should be writing my keystore password. I wasn't doing that, so that was why I wasn't able to change it. Now everything is working fine. ThanksEntire
Happy to know you resolved the issue.. Thanks to you too for accepting the answer.. Have a good day..Supplicatory
Is it possible to remove password of the keystore?Verda
AFAIK, the keystores normally don't work without password. If at all you need to do so, you may have to implement your own keystore logic by providing signing options in the logic while writing itself. You may google for such stuff maybe. Thanks!Supplicatory
Can I create the new keystore file using the same name and same alias with different password ?? Is it work for update the app?Descender
If you do not want to give the password in the command itself, simply do keytool -storepasswd -keystore "keystore location"Phenolphthalein
I strongly recommend making a backup of your keystore in case something goes wrong.Whizbang
In case you didn't see the Security note, you can at least delete those lines from your bash history using the history -d command unix.stackexchange.com/a/275101/247515Synovitis
The command in 3 needs -keypasswd after keytool. making it: keytool -keypasswd -keypass "previous password" -new "new password" -keystore "keystore location"Sherleysherline
I just wanted to know if this would still work or not.Daegal
P
30

The usage of keytool might have changed in the past years. What worked for me was:

  1. To change the password of an alias inside a store:

keytool -keypasswd -keystore pathToKeystoreFile -alias yourAlias -keypass oldAliasPassword -storepass oldStorePassword -new newAliasPassword

  1. To change the password of your keystore file:

keytool -storepasswd -keystore pathToKeystoreFile -storepass oldStorePassword -new newStorePassword

PSA: Make sure to backup your keystore file first in case you accidentally introduce any typos!

Proptosis answered 11/4, 2018 at 9:45 Comment(0)
W
23

We don't want to include the password as part of the command to avoid storing it in the shell history.

# Change the key password
keytool -keypasswd -alias "your_key_alias" -keystore "key_filename.key"
# Change the keystore password
keytool -storepasswd -keystore "key_filename.key"
Widmer answered 30/5, 2019 at 17:15 Comment(1)
This should be the accepted answer, you don't want to be writing your passwords into part of the command like the previous answers suggest, they'll get stored in your bash history in cleartextSanity
C
9

I could change password as below:

keytool -keypasswd -alias "key alias" -keypass "previous password" -new "new password" -keystore "/../.android/debug.keystore"
Cornela answered 5/2, 2015 at 12:13 Comment(2)
But, is it safe to change it if I have uploaded an app to google play with it?Entire
Yeah,. except that doesn't work if the old password was < 6 characters.Nernst
P
0

Android Studio 4.2.x this worked for me, go to the screen where you enter your passwords, if the box to save passwords is checked, uncheck the box, replace the good passwords with any jibberish and try to build your .apk. After it fails, go back and retype the good passwords and recheck the box to save passwords.

Pothook answered 1/12, 2021 at 12:22 Comment(0)
R
0

While I was using Bubblewrap, to generate a TWA APK by wrapping a PWA(deployed in netlify to get https link), I got struck at a point while building where my key & key-store password was wrong.

So, I manually deleted android.keystore file and ran

bubblewrap init --manifest=https://<my-twa.com>/manifest.json again. It asked me to generate new password, generated new key & key-store password and resolved my issue.

bubblewrap init --manifest=https://<my-twa.com>/manifest.json

bubblewrap build

you can observe android.keystore file

Rockel answered 9/6, 2023 at 6:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.