cannot find keytool on a mac
Asked Answered
J

7

16

I am trying to find my keytool so that I can make keys to sign my app and to register for the google maps api

I'm beginning to think that I don't actually have it on my machine

If anyone could help point me in the right direction that would be great

Jeaz answered 3/9, 2011 at 11:29 Comment(0)
F
8

If you are using Eclipse under Mac OS X you just need to
Select File -> Export -> select Android -> Export Android Application -> click next -> select your project -> click next -> here you just chose Create new keystore

False answered 3/9, 2011 at 12:0 Comment(1)
Actually this has only solved my issue in part. I now need to find my MD5 fingerprint, The guide on the android developers site says that I need to execute this line: $ keytool -list -alias alias_name -keystore my-release-key.keystore but there is now ".keystore" file in the folder that I specified when creating the keystore by your method, does this file get created in another folder?Jeaz
T
32

To answer the original question, on my Mac, keytool is found at /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/keytool.

You can locate the Java home directory using the /usr/libexec/java_home command line tool on Mac OS X 10.5 or later.

Terle answered 15/7, 2014 at 6:27 Comment(1)
C
8

The actual tool should be installed all ready, as to my knowledge it ships with the MAC. You then have to create the .keystore file http://www.androiddevelopment.org/tag/keytool/ shows how to do it

Congius answered 3/9, 2011 at 11:37 Comment(0)
F
8

If you are using Eclipse under Mac OS X you just need to
Select File -> Export -> select Android -> Export Android Application -> click next -> select your project -> click next -> here you just chose Create new keystore

False answered 3/9, 2011 at 12:0 Comment(1)
Actually this has only solved my issue in part. I now need to find my MD5 fingerprint, The guide on the android developers site says that I need to execute this line: $ keytool -list -alias alias_name -keystore my-release-key.keystore but there is now ".keystore" file in the folder that I specified when creating the keystore by your method, does this file get created in another folder?Jeaz
G
7

If you already have android studio installed, then keytool is located at

/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool

example to generate sha1 and sha256 using keytool

/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Gainly answered 2/1, 2021 at 14:20 Comment(1)
In my case it was found at /Applications/Android\ Studio.app/Contents/jbr/Contents/Home/bin/keytoolModestine
M
1

I did the following and it worked for me:

  1. /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/bin/keytool -genkey -v -keystore my-release-key.keystore -alias my_keystone -keyalg RSA -keysize 2048 -validity 10000
  2. jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk my_keystone
  3. /Users/developer/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 app-release-unsigned.apk nameapp.apk
Monotony answered 16/10, 2018 at 20:19 Comment(0)
P
0

Simply use your keytool command in Android Studio Terminal for Mac with a random password

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

you will get -

ga0RGNYHvrrrrrrMMPWQWAPGJ8=

Petrous answered 30/6, 2022 at 10:15 Comment(0)
E
0

If you have Android Studio installed on your mac,

  1. Go to Applications directory in your Finder app
  2. Control+Click on Android Studio app launcher
  3. Click "Show Package Contents" from the popup

For me, I was able to locate the keytool file and other java executable files in:

/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin 

To add this path to command line so you can run any executable file in the folder, you need to edit the terminal profile; .zshrc file for zsh(macOS Catalina or newer) or .bash_profile file for bash(older version of macOS). You can locate this file under user directory;

/Users/your_username/.zshrc

If the file is hidden, press (Command+Shift+.) to show hidden files

You can edit this file using your TextEdit app (you might need admin privilege to do this). Simply open the file and add this line, then save:

export PATH="/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin:$PATH"

Close your Command Terminal and open again. Run keytool

Eustoliaeutectic answered 30/4, 2024 at 6:26 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.