24
Book-Pro:main vy$ keytool -exportcert -list -v \
> -alias androiddebugkey -keystore ~/.android/debug.keystore
keytool error: java.lang.Exception: Only one command is allowed: both 
-exportcert and -list were specified.

I am trying to create a SHA1 on MBP for an android Firebase project. I pull the command from the Firebase console as described... https://developers.google.com/android/guides/client-auth

keytool -exportcert -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore

and I get an error. keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified.

I have tried hand typing this thinking that perhaps there is a problem with the browser. I installed new JDK... not sure what is going wrong here. assistance please

IrishGringo
  • 3,864
  • 7
  • 37
  • 49
  • 1
    I sort of fixed it... but Id still like comment. keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore observe I removed the -exportcert part. and I did get a sha1 back – IrishGringo Apr 06 '18 at 19:33
  • New duplicate but different wording (I didn't find this through search) - so will help getting to the answer faster: https://stackoverflow.com/q/59505659/7483211 Interestingly, when you Google just the error message this question doesn't show up at all - presumably because the error message is generic and also occurs in other situations. – Cornelius Roemer Dec 27 '19 at 20:24

3 Answers3

29

I sort of fixed it... but Id still like comments.

For Linux / UNIX:

keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore 

For Windows:

keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%/.android/debug.keystore

observe I removed the -exportcert part and I did get a sha1 back

FGM
  • 2,830
  • 1
  • 31
  • 31
IrishGringo
  • 3,864
  • 7
  • 37
  • 49
  • 3
    Although this indeed gave me a sha1, the sha1 is different from when I get it from the `signingReport` gradle task (cf [here](https://stackoverflow.com/a/34223470/3108590)). And when I add this sha1 into the Google Cloud Platform (in my case, for a Google Sign-In), it appears as not valid. If anyone has another solution to fix this issue, I'd love to hear it! – MathieuMaree Dec 11 '18 at 17:13
  • Agree, I've faced the same problem( – Vitaly Zeyenko Apr 14 '19 at 08:34
  • Your command works but this one adds the default password already in the command which makes things even less error prone and faster: ```keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android``` – Cornelius Roemer Dec 27 '19 at 20:25
1

for release key this one solved my problem

keytool -list -v -keystore C:\Users\MG\Desktop\test.jks -alias test
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Rajesh
  • 3,562
  • 7
  • 24
  • 43
0

For the following command worked.

keytool -keystore C:\Users\hp\.android\debug.keystore -list -v
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103