0

I want to generate a sha-1 so I can use the google maps v2 in my android app, im using oracles java jdk1.77.025 on ubuntu-mint. I get the following error:

marko@marko-K39a2 /usr/local/java/jdk1.7.0_25/bin $ keytool -list -v -alias androiddebugkey -keystore /home/marko/.android/debug.keystore -storepass android -keypass android
list: unrecognized option '-keypass'
list: Try 'list -help' for more information

this is very strange since I have build a key before and I never had problems. Thanks

user1796624
  • 3,665
  • 7
  • 38
  • 65

3 Answers3

1

if you put this somewehere in your app it will print it for you:

    try {
        PackageInfo info = getPackageManager().getPackageInfo("my.package.name", PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md;
            md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String something = new String(Base64.encode(md.digest(), 0));
            //String something = new String(Base64.encodeBytes(md.digest()));
            Log.e("hash key", something);
        }
    } catch (NameNotFoundException e1) {
        Log.e("name not found", e1.toString());
    } catch (NoSuchAlgorithmException e) {
        Log.e("no such an algorithm", e.toString());
    } catch (Exception e) {
        Log.e("exception", e.toString());
    }
Ivo
  • 18,659
  • 2
  • 23
  • 35
  • this worked, thanks, but i was hopping for a console solution, since i ahve a problem getting it from the console. Thanks for the answer – user1796624 Jul 27 '13 at 17:58
0

try to use this

keytool -list -v -keystore /home/marko/.android/debug.keystore

just skip the -alias and -keypass attribute use only this main attribute

Pratik
  • 30,639
  • 18
  • 84
  • 159
  • Enter key store password: android keytool error: gnu.javax.crypto.keyring.MalformedKeyringException: incorrect magic – user1796624 Jul 26 '13 at 12:29
  • Im asked for a password and when I enter android the default debug password i get: keytool error: gnu.javax.crypto.keyring.MalformedKeyringException: incorrect magic – user1796624 Jul 26 '13 at 12:30
  • Im asked for a pass, after putting: keytool -list -v -keystore /home/marko/.android/debug.keystore – user1796624 Jul 26 '13 at 12:33
  • Yes I am saying about this that after execute this cmd, it will prompt you for password then just enter press no need to provide password for this right now. When you pass -keypass or -storepass then only you need to provide same password after execute keytool cmd – Pratik Jul 26 '13 at 13:14
0

Run the following command to get your sha1: keytool -v -list -keystore "< debug.keystore path >" . check your debug.keystore path by windows-->preferences-->android-->build.

T_V
  • 17,440
  • 6
  • 36
  • 48