How to Add Sha-1 to Android Application

How to add SHA-1 to android application

SHA-1 generation in android studio:

change firebase project setting

Press add fingerprint button


  1. Select Gradle in android studio from right panel

  2. Select Your App

  3. In Tasks -> android-> signingReport

Double click signingReport.

How to get sha1 fingerprint


You will find the SHA-1 fingerprint in the "Gradle Console"

Add this SHA-1 fingerprint in firebase console

Add SHA1 fingerprint

SHA-1 fingerprint of keystore certificate

Follow this tutorial for creating SHA1 fingerprint for Google Map v2

For Debug mode:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 

for Release mode:

keytool -list -v -keystore {keystore_name} -alias {alias_name}

example:

keytool -list -v -keystore C:\Users\MG\Desktop\test.jks -alias test

On windows, when keytool command is not found, Go to your installed JDK Directory e.g. <YourJDKPath>\Java\jdk1.8.0_231\bin\, open command line and try the above commands for debug/release mode.

Another way of getting your SHA1 OR SHA-256 use ./gradlew signingReport

For more detailed info visit
Using Gradle's Signing Report

How to get the SHA-1 fingerprint certificate in Android Studio for debug mode?

Easiest ways ever:

Update added for Android Studio V 2.2 in last step

There are two ways to do this.

1. Faster way:

  1. Open Android Studio
  2. Open your Project
  3. Click on Gradle (From Right Side Panel, you will see Gradle Bar)
  4. Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
  5. Click on Your Project (Your Project Name form List (root))
  6. Click on Tasks
  7. Click on Android
  8. Double Click on signingReport (You will get SHA1 and MD5 in Run Bar(Sometimes it will be in Gradle Console))
  9. Select app module from module selection dropdown to run or debug your application

Check the screenshot below:

Sample Image

2. Work with Google Maps Activity:

  1. Open Android Studio
  2. Open Your Project
  3. Click on File menu -> Select New -> Click on Google -> Select Google Maps Activity
  4. A dialog would appear -> Click on Finish
  5. Android Studio would automatically generate an XML file named with google_maps_api.xml
  6. You would get debug SHA1 key here (at line number 10 of the XML file)

Check Screenshot below:

Sample Image

Android Studio V 2.2 Update

There is an issue with Execution.

Solution:

  • Click on Toggle tasks execution/text mode from Run bar

Check Screenshot below:

Sample Image

Done.

Get SHA-1 for Android Firebase

The issue is the slash (\) in your command. Make sure it is all on one line and remove any slashes (\). Also keep in mind that the command prompt interprets commands on a single line, so do not spread the command across multiple lines as it will treat everything on a new line as a different command. Put everything on one line.

Generate SHA-1 for Flutter/React-Native/Android-Native app

TERMINAL

Go to the project folder in the terminal.

Mac
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Windows
keytool -list -v -keystore "\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Linux
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

GUI Android Studio.

  1. Select android/app/build.gradle file and on the right top corner click "Open for Editing in Android Studio"

Sample Image


  1. Open Gradle panel and double click on "SigninReport",

see Android studio Gradle Tab

Sample Image


  1. That's it! If you use Firebase - add these 2 keys there. You should add both keys, otherwise, without the release key, Google login will not work on the devices.

Sample Image

how to get sha1 of android app in Vs code


  1. Open a terminal window.

  2. Change the directory to the JDK bin directory, mine was jdk1.7.0_05 (could be different for you).
    cd

    C:\Program Files\Java\jdk1.7.0_05\bin
  3. Next we have to run the keytool.exe. Use the following line to get the Android SHA1 fingerprint.
    Windows:

    keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore"-alias androiddebugkey -storepass android -keypass android

    Mac and Linux:

    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

How to add multiple SHA1 fingerprints to my Android App for testing?

Go to Google Cloud Platform Console or Firebase. You'll find the project there. Click on the project and you'll get into the dashboard of the same. In the bottom of the dashboard there'll be SHA key. Click add key and add the new key there. The Google Services which you have used in the app will run fine now.



Related Topics



Leave a reply



Submit