22

In React Native when I'm trying to get Google GPS API key in Google console, I have seen package name and SHA-1 key where to I get SHA-1 key in React Native

How to get SHA-1 key in React Native cli? (not in Expo).

karel
  • 5,489
  • 46
  • 45
  • 50
Balaji
  • 9,657
  • 5
  • 47
  • 47

12 Answers12

69
  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

    enter image description here

  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

    enter image description here

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.)

Vikas Bansal
  • 2,184
  • 2
  • 15
  • 18
  • 7
    this command is very useful "cd android && ./gradlew signingReport" to get report. Thanks. – Mostasim Billah Jul 13 '20 at 04:51
  • FAILURE: Build failed with an exception. * What went wrong: Could not open settings generic class cache for settings file 'C:\programming\zoomino 6\imaps-native\android\settings.gradle' (C:\Users\aseme\.gradle\caches\7.5.1\scripts\6ozn04tb0t0k7dwz97qf9fvs6). > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63 – IMPixel Jan 07 '23 at 01:13
14

There is debug.keystore available by default in android => app folder so we can use it to generate SHA1 key.

The command is as follows

keytool -exportcert -keystore ./android/app/debug.keystore -list -v

It will ask for password so just press Enter.

Husen B
  • 139
  • 1
  • 7
  • 1
    `keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified.` – Aliaksei May 19 '23 at 20:26
8

As far as I understand you, it's about Android.
You need input certificate fingerprint, what you use for sign *.apk file.
For generate SHA-1 fingerprint, open a terminal window and enter the following:

keytool -list -v -keystore PATH_TO_YOUR_KEYSTORE.keystore -alias YOUR_ALIAS_NAME -storepass YOUR_STORE_PASS -keypass YOUR_KEY_PASS

This should look something like this:

BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75

You can find more information here
If you don't have a certificate yet, I recommend you create it.
How to create a certificate you can read here.

7

if your are Using react native and using keytool -list -v -keystore ./android/App/debug.keystore -alias androiddebugkey -storepass android -keypass android
there are Chances getting ERROR

to Avoid ERROR in WINDOWS

1)Run your Command Prompt As Administrator

  1. Navigate to your react-native project's root folder

3)cd android

4)type in ./gradlew signingReport

this will generate All kinds of SHA-1 And SHA-256 and many more details

Imran Pasha I
  • 71
  • 1
  • 1
6

Get SHA1 Key

Simple run below command :

keytool -list -v -keystore ./android/App/debug.keystore -alias androiddebugkey -storepass android -keypass android
ANKIT DETROJA
  • 1,948
  • 1
  • 17
  • 24
  • 1
    this command is creating same SHA1 fingerprint for all projects. i even create new project and it gives the same fingerprint for all projects –  Nov 12 '19 at 08:20
2

Even though running keytool on jdk/bin and ./gradlew signingReport command gives SHA-1 & SHA-256 keys I had troubles when using those keys on firebase / gcp to register my app. For some reason running keytool command on project root folder output gives you a SHA-1 key which can be use to register the app in gcp. In windows, there are the steps you should follow

  1. Make sure keytool is the enviroment variable path
  2. Open the cmd in your root project folder (eg: C:/myreactnativeproject/)
  3. run keytool -list -v -keystore ./android/app/debug.keystore -alias androiddebugkey -storepass android -keypass android

And there is your SHA-1

CharukaHS
  • 561
  • 1
  • 5
  • 16
2

In your react-native root dir paste line below:

cd android && ./gradlew signingReport
holesx_x
  • 236
  • 4
  • 4
1

my solution: keytool -J-Duser.language=en -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Thanh Cao
  • 151
  • 5
1

first move to android folder cd android and than simply run .\gradlew signingReport command this help me on windows operating system

0

First Go To Your Project Directory And Just Simple Run This Command

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

And You Can Get enter image description here

Paresh Shiyal
  • 534
  • 4
  • 15
0
keytool -list -v -keystore you_key_name.keystore -alias your_alias_name
James Risner
  • 5,451
  • 11
  • 25
  • 47
0

For me the following command worked, as can be seen below.

keytool -keystore android/app/debug.keystore -list -v

result of the keytool command

Fabio Nettis
  • 1,150
  • 6
  • 18
lecbit
  • 1
  • 1