cannot find keytool on a mac - android

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

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.

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

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

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

I did the following and it worked for me:
/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
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk my_keystone
/Users/developer/Library/Android/sdk/build-tools/28.0.3/zipalign -v 4 app-release-unsigned.apk nameapp.apk

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=

Related

Get key hash for release

I have been trying to get my key hash for my release to work for hours now, and I must be doing something wrong because I have searched and tried so many different things,
Now lets say my alias is john_doe_key, and my keysotre is located at /Users/loaner/Downloads/UEat/app/app-release.apk
I would have my command in my terminal look like this correct?
keytool -exportcert -alias john_doe_key -keystore ~/Users/loaner/Downloads/UEat/app/app-release.apk | openssl sha1 -binary | openssl base64
or is that not right?
I have tried this and logging the key like face books says in the guide.
Thanks for the help in advance
From reading your comment and seeing what you have so far, you're trying to get the key hash for Facebook, right?
First, make sure that you have signed your apk (which is your app). You can sign your apk in Android Studio by Build -> "Generate Signed APK...". When you sign your apk, you create your keystore and an alias for that keystore. I think your are confusing "keystore" with the "apk".
Also, you have to include your alias and keystore passwords in your command.
It should look like this:
keytool -exportcert -keystore keystore_file -alias alias_name -storepass keystorepassword -keypass aliaspassword | openssl sha1 -binary | openssl base64
Also, make sure that you are creating a "Release Build", which can be selected from the Build Variants menu.
Generate a key store
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Sign an apk.
$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name

Keystore file doesn't exist

I'm trying to get the SHA1 fingerprint so I can get an Google API key.
Im in the following directory:
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin
Then I execute the command from the google site :
keytool -list -v -keystore mystore.keystore
But it gives this error:
keytool error: java.lang.Exception: Keystore file does not exist: mystore.keystore
java.lang.Exception: Keystore file does not exist: mystore.keystore
at sun.security.tools.keytool.Main.doCommands(Main.java:742)
at sun.security.tools.keytool.Main.run(Main.java:340)
at sun.security.tools.keytool.Main.main(Main.java:333)
I followed tutorials but I can't get it to work!
Does anyone know what I am doing wrong?
BTW: I'm using a Macbook Pro with Xamarin Studio 5.5.2.
Linux & Mac command
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Will give you SHA1, SHA256, MD5 for default debug key. And it can be used for developing and debugging with google play services.
For publication certificate just follow https://developer.android.com/studio/publish/app-signing.html
You said you are running the command from...
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin
Is your keystore file in that directory as well? If not then you need to specify the path to the keystore file, e.g.
keytool -list -v -keystore ~/somefolder/mystore.keystore
The keystore used should be the one used to sign the app. For Xamarin debug builds this will be the debug keystore located at /Users/[USERNAME]/.local/share/Xamarin/Mono\ for\ Android/debug.keystore. The command on OSX for this would be...
keytool -list -v -keystore /Users/[USERNAME]/.local/share/Xamarin/Mono\ for\ Android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Or on Windows 7
keytool -list -v -keystore C:\Users\[USERNAME]\AppData\Local\Xamarin\Mono for Android\debug.keystore -alias androiddebugkey -storepass android -keypass android
I faced the same issue, but resolved via following command:
keytool -exportcert -keystore C:\Users\<USERNAME>\.android\debug.keystore -list -v
OS: Windows 7
I have windows 10, I went to the route
c:/Users/usuario/.android/
Inside directory, execute command:
keytool -exportcert -keystore debug.keystore -list -v
Must generate fingerprint:
SHA-1: 73:BE:1A:.......................
MDO: 73:BE:A1.........................
SHA-256: 3B:B8:98:...................
Please provide the complete path of debug.keystore.
Example: C:/Users/myusername/.android/debug.keystore instead of ~/.android/debug.keystore
In my case the debug.keystore is generated after the first run of the app on Android Studio
I had the same issue.
My error was
keytool error: java.lang.Exception: Keystore file does not exist:/Users/[USER_NAME]/.android/debug.keystore java.lang.Exception: Keystore
file does not exist: /Users/[USER_NAME]/.android/debug.keystore
at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:910)
at java.base/sun.security.tools.keytool.Main.run(Main.java:416)
at java.base/sun.security.tools.keytool.Main.main(Main.java:409)
I checked my /Users/[USER_NAME]/.android/ directory and I couldn't find debug.keystore file there.
Reason:
I used VSCODE and I did run my application only for iOS through iOS Simulator.
Solution:
I opened Android Studio and run my application for android with Android Emulator.
Then I got debug.keystore file in my .android/ directory.
Then I tried command below again:
keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
And it runs without any error.
I hope it helps you.
I had the same error in Windows 10 as well. But sorted it and finally got SHA-1 Key.
I followed these steps
1.Open C drive and follow this path C:\Program Files\Java\jdk1.8.0_201\bin .
2.Inside bin folder open CMD and run command keytool -exportcert -list -v -alias androiddebugkey -keystore C:/Users/Username/.android/debug.keystore . (Replace Username with your username).
3.Enter password as android .
Linux or Mac or Windows, use complete path
Mac:
keytool -list -v -keystore /Users/username/.android/debug.keystore
-alias androiddebugkey -storepass android -keypass android
Linux (Ubuntu in my case):
keytool -list -v -keystore /home/username/.android/debug.keystore
-alias androiddebugkey -storepass android -keypass android
Windows:
keytool -list -v -keystore C:\Users\username\.android\debug.keystore
-alias androiddebugkey -storepass android -keypass android
Hope it work for you!
I found this guide from teamtreehouse forum. hope it'll help you.
1) Open Command Prompt by pressing Start+R and typing cmd.exe.
2) Using Windows Explorer, find where your JDK directory is located (Usually Program Files >> Java) and copy the path.
3) In Command Prompt, type cd followed by the directory of your JDK’s bin directory. e.g: cd C:\Program Files\Java\jdk1.8.0_25\bin is the command I use (Yours may vary).
4) Using Windows Explorer, find where your .android directory is located (Usually under Users >> [YOUR WINDOWS USERNAME]) and copy the path.
5) Now, use this command below:
keytool -exportcert -alias androiddebugkey -keystore[PATH_TO_.ANDROID_DIRECTORY] -list -v
Replacing [PATH_TO_.ANDROID_DIRECTORY] with the path you copied. Note that you should be running this command in terminal/command prompt in your JDK’s bin directory (You did this in Step 3).
Mine is C:\Program Files\Java\jdk1.8.0_121\bin>keytool -exportcert -alias androiddebugkey -keystore C:\Users\HoSiLuan\.android\debug.keystore -list -v
Remember to use C:\Users\HoSiLuan\.android\debug.keystore instead of ~/.android\debug.keystore. I still got the error when type this shorten way.
You should then be prompted with the password as normal which you can enter (The password is android) . After that, you’ll see the list of certificates printed to the screen.
If you are on Windows open command prompt and RUN AS ADMINISTRATOR then paste the line keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore. That should work, it worked for me
I lived same problem on Windows 10 and solved that problem with writing below command:
keytool -list -keystore debug.keystore
I think with some other commands java couldn't find debug.keystore file but interestingly with that command it works for me.
I had the same Error
am using ubuntu 18.04
Solution:
Open terminal and navigate to /home/{$user}/.android
Then run the command
keytool -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore
You will be prompted to enter a keystore password enter android
Hope this helps.
Below command should work:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
So I have found the solution.
On Windows, open cmd from start menu and write cd C:\Users\put_here_your_username\.android and then write
keytool -list -v -keystore ".\debug.keystore" -alias androiddebugkey -storepass android -keypass android
last update for Mac & Ubuntu
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v
I faced the same problem, I found that I had .android folder inside another .android folder. Make sure to find the right path of debug.keystore file on your system
I used this command and it worked
keytool -list -v -alias androiddebugkey -keystore C:\Users\User.android.android\debug.keystore
keytool -list -v -keystore C:\Users\%USERNAME%\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
Try this to get resolve from the problem
If you are on Windows open command prompt and then Run it as an administration then paste this: keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%.android\debug.keystore
use password : android
then you will get SHA-1 and SHA-256 this worked smoothly for me.
Install keytool on your system
Keytool is included as part of the Java runtime. So by installing Java, you'll also have keytool in your system.
To install Java, visit the JAVA SE Downloads page. Then, select the JDK Download link.
After that, add the keytool folder to your system %PATH% (on Windows). In order to run keytool from the command line, you need to add it to your system PATH. This step is required on Windows only.
Finally, run this command in a terminal, and don't forget to change the user name to your own:
keytool -list -v -keystore "c:\users\your_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Open CMD and navigate to Java bin folder for example:
C:\Program Files\Java\jre1.8.0_341\bin
Once you stand here then paste this:
keytool -exportcert -list -v -alias androiddebugkey -keystore C:/Users/*YOUR_PC_USERNAME*/.android/debug.keystore
Do not forget to change to your own PC username marked with * YOUR_PC_USERNAME *
Double check that you are putting the correct address in my case I had two typos and that fixed it.
I had c:User instead of C:\Users\
Find your debug.keystore file by searching (usually it is in .android) and then use this
keytool -list -v -alias androiddebugkey -keystore "C:\Users\u_name\ .android\debug.keystore"
Use your own full path name not copy paste from anywhere.
It solved mine and this or some else solution will solve yours too😄.
just put this given command in your package.json file and hit run yarn sha-keys
"sha-keys": "keytool -list -v -keystore ./android/App/debug.keystore -alias androiddebugkey -storepass android -keypass android",

Failure [install_parse_failed_no_certificates] when attempting to install APK to the emulator

I downloaded Myfiles.apk from the internet and I'm trying to install it to my Android emulator.
While installing Myfiles.apk file through the command prompt, I'm getting this error.
I tried following in command prompt
C:\android-sdk\tools> adb -s emulator-5554 install C:\Users\Me\Desktop\MyFiles.apk
How do I install this APK to the emulator correctly?
This site
helped me a lot to properly sign the unsigned apk. But,for the last process i.e. for jarsigner,following command need to be used
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name.
Further do look upon this unable to sign zipexception if you encounter with any zipexception error . So overall,use following procedure
keytool -genkey -v -keystore debug.keystore -alias android -keyalg RSA -keysize 2048 -validity 20000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore yourapkalign.apk alias_name
zipalign -v 4 yourapk.apk yourapkalign.apk
Now,you can successfully install the apk file.
It means that the apk you downloaded hasn't been signed with any certificate, debug or otherwise.
You can sign it from the command line, as described here.
You can use the androiddebugkey the sign the apk.
The keystore lives in ~/.android, named debug.keystore.
Run
keytool -list -keystore ~/.android/debug.keystore
To see the debug key, we can see its name is androiddebugkey
Run the following command to sign the apk.
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore yourapp-release.apk androiddebugkey

There is no debug.keystore in .android folder

Someone I'm helping with an application needs to locate her debug.keystore - mine is in my .android folder, but when I navigate there on her computer it is not there.
Does something need to be done in order for it to appear? Where is it / how can it be generated again?
According to the documentation, performing a build in Eclipse or using ant debug should automatically generate ~/.android/debug.keystore.
But in case this doesn't work, you can create one manually by running:
keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"
If she is using Eclipse then go to Windows -> Preferences
Select Android -> Build
There you will see Default debug keystore: "Path"
See if you can locate it there.
You can create keystore using this command..
keytool -genkey -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
The debug.keystore is created automatically on first build that uses it.
On Windows 7, I had to create the file manually using John's suggested command. Don't forget to enclose the path in a pair of double quotes (").
I don't know how it work magically!
I deleted my debug.keystore, build my project again and look for debug.keystore in default location ~/.android/debug.keystore, din't find debug.keystore.
Again build project and look for debug.keystore, no luck!
Then I open eclipse go to Windows -> Preferences,Select Android -> Build
See Default debug keystore: "Path".
Now again looked for debug.keystore in default location ~/.android/debug.keystore, found debug.keystore.
Tried so many times, it worked.
try this....it will generate the file debug.keystore to
C:/
for all versions of Windows
keytool -genkey -v -keystore C:/debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 999999 -dname "CN=Android Debug,O=Android,C=US"
Try this for Generating PKCS keys.
keytool -importkeystore -srckeystore C:\Users\xxx\.android\debug.keystore -destkeystore C:\Users\xxx\.android\debug.keystore -deststoretype pkcs12
Note: RSA2048 is not a recommended industry standard and the above command can be used to migrate the existing debug.keystore in RSA2048 to PKCS format
The old debug.keystore which was in RSA2048 will be renamed to debug.keystore.old and saved automatically
To get the key you should first run the app on a device(real device or emulator). While debugging the file is automatically created.
debug.keystore automatically generate after the run of the app debugging

How do I generate an android debug.keystore from the command-line?

I'm using a GUI-less linux so I can't use Eclipse to generate one for me.
look at Android's documentation for creating a keystore using keytool. They provide an example command:
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Edit: Sorry, I read too quickly. If you want to use a debug keystore from the command line, you need to compile using "ant".

Categories

Resources