How to generate a different debug sha1-key - android

I have a sha1 Key for debug that I get from signinreports inside android studio. Now, I have this key in multiple Firebase projects, and I would like to generate another debug key for this project.
How can I generate another debug key for an existing project and assign it to that project ?
I have tried with
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
But is outputting the same debugkey as the other projects

Step 1) Go to File > Project Structure > select project > go to
"signing" and select your default or any keystore you want and fill
all the details. In case you are not able to fill the details, hit the
green '+' button.
Step 2) VERY IMPORTANT: Goto Build Types> select your build type and
select your "Signing Config".
https://stackoverflow.com/a/17992232/4853835
Another solution: you can move (move to a backup folder) keys from this directory then build your project (Android studio will create new key):
For Windows User: C:\Users\USERNAME.android\debug.keystore (Change USERNAME as your pc name)
For Linux or Mac OS User: ~/.android/debug.keystore

Related

How to add the debug signing certificate and get (SHA-1) from command propmt

when i open command prompt it look like this
so when i write the command of getting the SHA-1 that what happend
If you want to go for Debug Mode:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
EDIT try this:
Getting your SHA1 key is a little more complicated on a Windows system so, follow along with my steps here:
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).
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. You want the SHA1 key.
In Command Prompt, it’s a little more tricky to copy the result so, to do that, follow these instructions:
1) Right-click on the Command Prompt.
2) Select Mark.
3) Highlight the SHA1 key.
4) Right-click again and the text will then be copied to your clipboard. You can now enter this on the Google Developer’s Console.
Open Android Studio
Open Your Project
Click on Gradle (From Right Side Panel, you will see Gradle Bar)
Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
Click on Your Project (Your Project Name form List (root))
Click on Tasks
Click on android
Double Click on signingReport (You will get SHA1 and MD5 in Run Bar)

Android Studio only gives me SHA1, I need SHA256

I want to use assetlinks.json for appindexing.
I am supposed to use a SHA256 fingerprint, but when I print out the signingReport in Android Studio, I only have SHA1.
Can I use SHA1? If not, how can I get a SHA256 signed app?
Using Manish Jain's answer, I have managed to list only the debug keys. If I put my actual keystore path and jks file in the path:
keytool -list -v -keystore "C:\Users\myself\Keystores\android.jks" -alias mykey -storepass 1password -keypass 2password
A different set of keys come up, which I assume would be the release key set.
The BIG QUESTION is why Android Studio only lists the debug keys when I print out the signingReport from Gradle and why it says Variant: releaseUnitTest, Config: none? Any idea?
You can get SHA256 by using keytool using command prompt (windows).
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
For Mac users:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
If you have any special characters in your password, you may need to wrap the password in single quotes.
There is a much simpler and updated method to find it, comes from this answer.
Navigate to the Gradle tab at the right side of Android Studio.
In the list, navigate to the app section and expand it.
In the expanded list, navigate to the Tasks section and expand it.
Again, in the expanded list, navigate to the android section and expand it.
Double-click on signingReport, and find the SHA-256 Fingerprint at the Run box.
You will find your SHA-256 Fingerprint there.
As #quent commented, change your run configuration in the main toolbar to run the debug configuration again.
Go to the root directory of the project from the terminal and run the below command
./gradlew signingReport
You will get SHA-1, SHA-256, and other details
You can get it from the Google Play Console (https://play.google.com/apps/publish). Follow these steps:
Go to your project in GPC.
Expand "Release Management".
Go to "App signing".
Navigate to "App signing certificate".
Copy SHA-256 fingerprint.
I always find using ./gradlew signingReport effective and good for me.
Just run the command in your project terminal.
Navigate to the Gradle tab on the right side of Android Studio
Expand the project name
Expand Tasks
Expand Android
Double click on signingReport
As of 2021, in the latest Android Studio:
Navigate to the Gradle tab on the right side of Android Studio.
In the list, navigate to the app section and expand it. If you see the Tasks section in the expanded list, then follow this answer and you are good to go.
If you are not able to see the Tasks section then the alternate is:
Click the elephant button Execute Gradle Task on the upper left of the gradle tab, and then type in:
gradle signingReport
and it will print the SHAs in the console.
go to play console dashboard->App integrity ->app signing you will see SHA-1, SHA256 and MD5 keys
The tried solution: Upgrade your Gradle version
distributionUrl = https \: //services.gradle.org/distributions/gradle-5.4.1-bin.zip in gradle-wrapper.preperties
after that
Navigate to the Gradle tab on the right side of Android Studio
Expand the project name
Expand Tasks
Expand Android
Double click on signingReport
If you need it automated, you can extract the value from signingReport gradle task output like this:
function signing_certificate_digest() {
./gradlew app:signingReport | \
awk "/^Variant: $1\$/,/SHA-256|---/" | \
grep 'SHA-256' | \
cut -d' ' -f2
}
Which you can use like this in command line:
signing_certificate_digest debug
Also note:
When using Play App Signing, the signature of the binary signed by the upload key certificate will be different than the binary distributed by Google Play.
So this may not be suitable in that case.
Migrating OP's solution from the question to an answer:
For Release:
Go to: C:\Program Files\Java\jdk1.7.0_25\bin (or wherever your jdk file is).
Type cmd in address bar in win explorer.
Add: keytool -list -v -keystore "C:\Users\yourUserName\Keystores\android.jks" -alias yourAppName -storepass yourPasswordToKeystore -keypass yourPasswordToRequiredAppKey
Be careful!!!
If you have multiple keys in the keystore, it might not give you the
correct matching one to the given app!
Another way of getting the SHA256 for your app:
Either on the Developer Console or Firebase, you can find the related
SHA256 key somewhere. I couldn't find it now, but if you keep looking,
it is there somewhere.
I just found it on the Google Play Developer Console:
Upload the first version of your app (if you haven't done it yet)
Go to App Releases in Release Management
Click Manage Beta
At the APK version click the "i" info button on the right
It will show you the SHA keys

How to obtain SHA-1 Fingerprint for keystores which are created by Xamarin Studio?

When you sign and distribute your Xamarin Android apps the wizard helps you create keystore for your app. However, wherever I looked on my mac I could not find the actual .keystore file anywhere. So how am I supposed to get the SHA-1 fingerprint for that keystore?
SHA1 fingerprints are stored within the same keystore files.
Visual studio has an unique feature to open such files.
Just double click the file after creating it inside Xamarin. It will give you the SHA1 Fingerprint.
For windows users,
Go to this path or where ever you have your keytool.exe file
C:\Program Files\Java\jre7\bin
Hold shift key and right click -> then select Open command window here
After commandline open paste this command
keytool.exe -list -v -keystore "%LocalAppData%\Xamarin\Mono for Android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Official document here - https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/MD5_SHA1/
This questions a few months old, but in the event others were stymied by this and end up here - here's instructions for mac users:
When you use the Android Signing wizard it asks for an alias and password.
Generate the SHA1 by entering by opening a terminal window and entering:
keytool -list -v -keystore /Users/[USERNAME]/Library/Developer/Xamarin/Keystore/[ALIAS]/[ALIAS].keystore -alias [ALIAS]
It will then prompt you for the password and if happy with that, will return certificate info and fingerprints (including the SHA1).
Note two passwords aren't needed as mentioned in the Xamarin documentation here.
(And if like me you were searching in Finder for the keystore file you created with no luck, it's because the Library folder is hidden)

SHA1 certificate fingerprint

I am trying to make an app that can communicate with Google Cloud Messaging.
I have looked at some tutorials and read a lot of stuff, but it all skips one point. When configuring an Android Key for API Project it asks for a SHA1 certificate fingerprint.
How do I find this (I have eclipse and windows 7)?
Any help would be appreciated.
Here is how to get it :
In Eclipse, if you go to Windows ->Preferences -> Android -> Build.
You can get SHA1 from here using the steps and Keystore Password with be "android".
if you are working in android (Google drive apps, Google Map apps), and you need SHA1 or MD5 then follow this step to get your SHA1 and MD5.
Open Eclipse
Windows-->Preferences-->Android-->Build (Here you will got a path to your "debug.keystore"
Copy this path.
Find out where is your jdk (like in my system "C:\Program Files\java\jdk1.6\bin "
Now open TERMINA(cmd) and change the directory to the bin , like c:\ cd "C:\Program Files\java\jdk1.6\bin"
Now after that copy-paste this code in your terminal
keytool -list -v -keystore "C:\Users\pir fahim shah.android\debug.keystore" -alias
androiddebugkey -storepass android -keypass android
you can change your "debug.keystore" file address here.
Some snapshot which will show my process
Found debug keystore file on Mac with Android Studio at ~/.android/debug.keystore
keytool -list -v -keystore ~/.android/debug.keystore
Open Android Studio
Open Your Project
Click on Gradle (From Right Side Panel, you will see Gradle Bar)
Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
Click on Your Project (Your Project Name form List (root))
Click on Tasks
Click on android
Double Click on signingReport (You will get SHA1 and MD5 in Run Bar)
Check app run console bar
I found a very easy process to find you MD5, SHA-1 fingerprint using Android Studio.
Run your project
Go to Gradle Menu (Menu: View -> Tool Windows -> Gradle)
Go to 'signingReport' in Gradle window. (Your project -> Tasks -> android -> signingReport)
Run it. (Using double-click or Ctrl + Shift + F10)
In Run window you will find all info.
The best solution for generating SHA1 key for android is from android studio.
Click on Gradle on far right side
Click on refresh icon and you will see the name of the app
Click on the Tasks -> Report -> Signing Report
Find the SHA1 Key on bottom part in console
For Debug Version of SHA1 key open terminal and enter the following command.
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Note: If you find any error you may need to change path of your debug.keystore file(In my case it is "/.android/debug.keystore").
For Release Version of SHA1 key, first you need to generate signed apk. After that you will get .jks file. Then apply the following command in terminal.
keytool -list -v -keystore ~/.android/release.jks -alias ProjectName
Note: If you find any error you may need to change path of your release.keystore file(In my case it is "/.android/release.keystore").

How to obtain Signing certificate fingerprint (SHA1) for OAuth 2.0 on Android?

I'm trying to register my android app following the steps in https://developers.google.com/console/help/#installed_applications which leads me to follow
http://developer.android.com/tools/publishing/app-signing.html.
However, I'm not sure how to get the signing certificate fingerprint (SHA1).
I first used the Eclipse ADT plugin to export and create the keystore/key.
Then, I tried doing keytool -list keystore mykeystore.keystore and it gives me a MD5 Certificate fingerprint. Do I need to redo the signing (meaning I can't use the eclipse export wizard)?
Can I use a debug certificate first?
Start an export process to create an apk for your app and use your production key. The very last page displays both your SHA1 and MD5 certificate fingerprints
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
I think this will work perfectly. I used the same:
For Android Studio:
Click on Build > Generate Signed APK.
You will get a message box, just click OK.
Now there will be another window just copy Key Store Path.
Now open a command prompt and go to C:\Program
Files\Java\jdk1.6.0_39\bin> (or any installed jdk version).
Type keytool -list -v -keystore and then paste your Key Store
Path (Eg. C:\Program Files\Java\jdk1.6.0_39\bin>keytool -list -v
-keystore "E:\My Projects \Android\android studio\signed apks\Hello World\HelloWorld.jks").
Now it will Ask Key Store Password, provide yours and press Enter to get your SHA1 and MD5 Certificate keys.
If you are using Mac or even Linux, just copy and paste this onto the Terminal application and you will get the SHA1 key immediately. No need to change anything.
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Example output:
Alias name: androiddebugkey
Creation date: 17 Feb 12
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 4f3dfc69
Valid from: Fri Feb 17 15:06:17 SGT 2012 until: Sun Feb 09 15:06:17 SGT 2042
Certificate fingerprints:
MD5: 11:10:11:11:11:11:11:11:11:11:11:11:11:11:11:11
SHA1: 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:01:11
Signature algorithm name: SHA1withRSA
Version: 3
use this in the command line
c:\Program Files\Java\jdk1.6.25\bin>keytool -list -v -keystore c:\you_key_here.key
Open terminal (in Unix, in MAC), (cmd in Windows) and cd to this (your java) path:
C:\Program Files\Java\jdk1.6.0_43\bin>
Run this command:
keytool -list -v -keystore C:\Users\leon\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
Just change the path to debug.keystore and you will get both MD5 and SHA-1 fingerprints.
keytool -list -v -keystore "keyStoreName"
Run this command from the directory where the keystore of your app exists.
In Android Studio, follow these steps:
Click Gradle properties menu at right side of your android studio IDE.
Expand Task tree.
Click on signingReport
You can see your SHA1 at the bottom console
See if you want to use Google Map at that time you need MD5 fingerprint for generating api kay for using google map in your android application.
Keytool command generated MD5 fingerprint if you use JDK 1.6 and it generates SHA1 fingerprint if you use JDK 1.7.
So the thing is that if you want to sign your application for publishing then read this.
And if you want to use google-map read this.
If you are using IntelliJ (12+?), go to menu Build/Generate signed Api
After filling a popup, get the data in the field "key store path" (e.g. C:\Users\user\Documents\store\store)
And run in a command line:
>keytool -list -v -keystore "C:\Users\user\Documents\store\store"
....
MD5: 11:C5:09:73:50:A4:E5:71:A2:26:13:E0:7B:CD:DD:6B
--> SHA1: 07:0B:0E:E8:F7:22:59:72:6A:1C:68:05:05:CF:2E:6F:59:43:48:99
SHA256: E6:CE:DA:37:C1:18:43:C1:A3:F0:9E:8F:1A:C2:69:AF:E6:41:F7:C0:18:
1D:1D:55:5D:F0:52:6C:EE:77:84:A7
...
Good luck
If any one using the Android studio...
click: Build > Generate Signed in APK
Create a new key: this will generated ".jks" files
Use following command to read the data(SHA1 and other info):
$ keytool -list -v -keystore filename.jks
For those using OpenSSL you can retrieve the SHA1 fingerprint this way:
OpenSSL> dgst -sha1 my-release-key.keystore
Which would result in the following output:
I was so confusing first time, but I propose you final working solution for Windows:
1) Open cmd and go to your Java/jdk/bin directory (just press cd .. to go one folder back and cd NAME_FOLDER to go one folder forward), in my case, final folder: C:\Program Files\Java\jdk1.8.0_73\bin>
2) Now type this command keytool -list -v -keystore C:\Users\YOUR_WINDOWS_USER\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
As result you have to get something like this:
Here is my easy solution for this:
Click on Gradle button, you can find at the right side top. you will see all the gradle files. Now go to android, and double click on signingReport. Once the gradle build finishes, you see the SHA key. Check the below images for step by step guide.
Once you click on Gradle check the below images. Hope this helps someone.
STEP 1:
STEP 2:
If you are using Android Studio. You can get fastly the SHA1 certificate fingerprint (debug,release... all Build Types!!) through Gradle Tasks:
signingReport
SHA1 is shown in Messages Logs
Android Plugin (configured in the gradle app) creates a debug mode for default.
com.android.application
File route to keystore:
HOME/.android/debug.keystore
I recommend attach debug.keystore to build.gradle. To do this put a file debug.keystore to a app folder and then Add SigningConfigs in gradle app:
apply plugin: 'com.android.application'
android {
................
signingConfigs {
debug {
storeFile file("../app/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
release {
storeFile file("../app/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
........
}
Extra: If you want creates for release, put a file release.keystore to a app folder. (This example uses the same debug.keystore)
If you are using Android Studio. You don't need to generate a SHA1 fingerprint using cmd prompt. You just need to create a project with default Maps Activity of Android Studio.In the project you can get the fingerprint in google_maps_api.xml under Values folder. Hope this will help you. :)
Try this One:
Windows----preferences----Android--build---sh1 code copy from here
I think this will work perfectly. I used the same:
For Android Studio:
Click on Build > Generate Signed APK.
You will get a message box, just click OK.
Now there will be another window just copy Key Store Path.
Now open a command prompt and go to C:\Program Files\Java\jdk1.6.0_39\bin> (or any installed jdk version).
Type keytool -list -v -keystore and then paste your Key Store Path (Eg. C:\Program Files\Java\jdk1.6.0_39\bin>keytool -list -v -keystore "E:\My Projects \Android\android studio\signed apks\Hello World\HelloWorld.jks").
Now it will Ask Key Store Password, provide yours and press Enter to get your SHA1 and MD5 Certificate keys.
Now add this SHA1 key to the google developers console in credentials tab and also change the build variants in android studio to release mode.
Please Click on Gradle from Right side of Menu
Then Click on :app
Then Click android folder
Then SigningReport file name is exist there
Double click on that.
It Will start executing and in a while it will show you SHA-1 Code
Just copy the code.
And paste it where you need it
For those on mac looking for keytool. follow these steps:
Firstly make sure to install Java JDK
http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
Then type this into command prompt:
/usr/libexec/java_home -v 1.7
it will spit out something like:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
keytool is located in the same directory as javac. ie:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin
From bin directory you can use the keytool.
If you are on Mac/Linux, then you can get SHA1 fingerprint by writing following line in the terminal:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
There are 2 things possible after this
It will ask you for the password
Just type
android
and press enter, you can find the SHA1 key in the output shown below.
It will ask you to download a suitable program (and some list will
be given)
Just type following in terminal
sudo apt install openjdk-8-jre-headless
and then again run following in terminal: keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
This time, you will be led to step 1, where you need to just enter the password as
android
and you will get your SHA1 fingerprint below in the output.
Open your command prompt
Navigate working directory to 1.8.0/bin
paste keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
Press enter if it ask you a password
If you want to obtain fingerprint-sha1 key from signing keystore.jks file
Run the following command from terminal:
keytool -list -v -keystore <.../path/keystore.jks>
Example
keytool -list -v -keystore /Users/Home/Projects/Keystore/myApp_keystore.jks
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 1 entry
Alias name:myApp_alias
Owner: CN=xxx, OU=xxx Dev, O=ZZZ, L=Dhaka, ST=Dhaka, C=BD
..........
Certificate fingerprints:
MD5: 12:10:11:12:11:11:11:11:11:11:33:11:11:11:11:11
SHA1: 11:44:11:11:55:11:17:11:11:66:11:11:88:11:11:77:11:11:01:11
.....................
Using portecle :
File > Open Keystore file
Enter Keystore password
Right click on alias name > Certificate details > SHA-1 Fingerprint
Easiest way to Get SHA-1 For Release and Debug mode android studio gradle. Check this
I wanted to post a notice to those that are having the same issue as me. I went through the steps to generate my debug SHA-1 and my release SHA-1. I was attempting to connect Google Sign-In API with my app.
I ran into the issue that the debug .apk would work fine, it would connect and authenticate with Google Sign-In. My release .apk would also work, when installed manually to the phone. When I posted my release .apk to the Google play store, my google Sign-in would not authenticate and I would get an issue!
For the longest time I couldn't figure it out, but I found that my app was being signed by google, i.e., the message on the top of the Developer console was showing: Google Play App Signing is enabled for this app.
I went to my Release Management tab, then scrolled down to App Signing, and found the SHA-1 there. After adding this to my code and on "firebase console" which I was using as the backend for Google Sign-in, everything seemed to work. It looks like my release keystore was getting replaced with the google signed certificate... I'm not really sure if this is what was happening, but it resolved my issue and allowed my Google Play Store release apk to correctly authenticate with the google sign in!
Step by step solution:
Open your command prompt or Terminal for Mac
Change directory to directory of the keytool file location. Change directory by using command cd <directory path>. (Note: if any directory name has space then add \ between the two words. Example cd /Applications/Android\ Studio.app//Contents/jre/jdk/Contents/Home/bin/)
To find the location of your keytool, you go to android studio..open your project. And go to
File>project Structure>SDK location..and find JDK location.
Run the keytool by this command:
keytool -list -v –keystore <your jks file path> (Note: if any directory name has space then add \ between the two words. example
keytool -list -v -keystore /Users/username/Desktop/tasmiah\ mobile/v3/jordanos.jks)
Command prompt you to key in the password.. so key in your password.. then you get the result
Here is tool for lazy coders:
1 add dependency:
compile 'com.vk:androidsdk:1.6.9'
2 add following lines somewhere in your activity/application:
String[] fingerprints = VKUtil.getCertificateFingerprint(this, getPackageName());
Log.d("SHA1", fingerprints[0]);
3 Open logcat and catch message.
4 Profit!
In latest version of Android Studio best way to get the SHA-1 key is form terminal. ,
open terminal in Android studio
Copy the
command( keytool -list -v -keystore ~/.android/debug.keystore -alias
androiddebugkey -storepass android -keypass android)
Paster it on terminal and press the enter key

Categories

Resources