0

i am currently doing a tutorial on how to log in via google + account but im stuck in the first step. the tutorial im talking about is tutorial. i have a print screen of what i did but its not working enter image description here what seem to be wrong here? is there any other way to generate the same file without using the command prompt

UPDATE

was able to run the line but it return a different result than that of in the tutorial it returned this one enter image description here

Paul Collingwood
  • 9,053
  • 3
  • 23
  • 36
Giant
  • 1,619
  • 7
  • 33
  • 67
  • 1
    The program `keytool` is not on your `PATH` environment variable. Make sure it's installed properly and that your `PATH` variable includes the path to its installation directory. Alternatively you can `cd` to the directory where the binary lies, and execute it from there. – reto Mar 27 '14 at 08:33
  • @reto what do you?i need to change directory to keytool?is it found in the sdk folder? – Giant Mar 27 '14 at 08:35
  • is there any other way to get this sha1 i cant find the path – Giant Mar 27 '14 at 08:41
  • try jump to this path C:\users\mmanlaing\.android> keytool -exportcert -alias androiddebugkey -keystore C:\path\to\.android\debug.keystore -list -v – MilapTank Mar 27 '14 at 08:46
  • check this update sir – Giant Mar 27 '14 at 08:47

4 Answers4

2
try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "com.example.yourpackagename",
                    PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash:",
                        Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        } catch (NameNotFoundException e) {

        } catch (NoSuchAlgorithmException e) {

        }

I know this question has been answered but this is how I found my signature for the default keystore. In Eclipse, if you go to Windows -> Preferences -> Android -> Build

see

Android
  • 8,995
  • 9
  • 67
  • 108
0

If you are using eclipse,You can get the SHA-1 in last page of apk export wizard (ie., it is given inbetween edit box and the finish button ).

you can also add any keystore through custom keystore option available in eclipse. There also the SHA-1 is given after you add a keystore as a custom one.

you can get more details here

Community
  • 1
  • 1
zelva
  • 1
  • tried this approach but its a bit complicated than the one said above i think i'll stick with the one above and try to figure out how to generate it properly..i tried your approach but i didn't work out well – Giant Mar 27 '14 at 09:07
0

please go jdk bin path

cd C:\Program Files\Java\jdk1.6.0_22\bin

then

keytool -list -v -keystore "C:\Users\mmanlapig\.android\debug.keystore"

OR

try this code.It will return hash key in your log cat. and dont forget to change the package name

try {
            PackageInfo info = context.getPackageManager().getPackageInfo(
                    "com.example.package", PackageManager.GET_SIGNATURES); //Your package name here
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.v("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
                }
        } catch (NameNotFoundException e) {
        } catch (NoSuchAlgorithmException e) {
        }
Kanaiya Katarmal
  • 5,974
  • 4
  • 30
  • 56
0

install the keytool on eclipse using the following steps then u can generate SHA-1 easily

http://keytool.sourceforge.net/update

in eclipse take help->install new software. copy the above url to it and install it.then you have an option keytool on eclipse. select keytool->open keystore. browse the path of the debug.keystore file and give password as android.enter image description here