Generate Sha-1 for Flutter/React-Native/Android-Native App

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 SHA-1 key in React Native cli?

  1. Windows:

    – Open a terminal window

    – Change the directory to the JDK bin directory. The path of the JDK depends upon the operating system you are using

    cd C:\Program Files\Java\jdk1.8.0_121\bin

    – Now we have to run the following command using the keytool.exe file in JDK/bin

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

    Sample Image

  2. Ubuntu/Mac

    – Open a terminal window

    – Now run the following command

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

    Sample Image

For more details click Here


  1. From React-native Project:

    – Run this command in React-Native App directory

    cd android && ./gradlew signingReport

    – copy the SHA1 from the debug key (This generates two variant keys. You can copy the 'SHA1' that belongs to the debugAndroidTest variant key option.)

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.

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

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 do I generate SHA-1 for Flutter app from Linux command line

Run gradlew signingReport from the android directory under the root of your flutter project:

myflutterproject/android$ ./gradlew signingReport

This assumes you have JAVA_HOME and PATH to bin directory set.

If you do not have the full JDK installed, the location of the Java Runtime Environment (JRE) embedded with Android Studio can be found by running:

$ flutter doctor -v

With a default Android Studio installation the location of the JRE should be:

/opt/android-studio/jre/bin/

To set the JAVA_HOME environment variable and PATH to the bin directory, add the following lines to your ~/.bashrc file:

export JAVA_HOME=/opt/android-studio/jre
export PATH=$PATH:$JAVA_HOME/bin

(Close and reopen the terminal window before use)



Related Topics



Leave a reply



Submit