Generate SHA-1 for Flutter/React-Native/Android-Native app
Solution 1
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.
- Select android/app/build.gradle file and on the right top corner click "Open for Editing in Android Studio"
- Open Gradle panel and double click on "SigninReport",
- 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.
Solution 2
This is the easiest way-
-
Open Android Studio
-
Open Project
-
Reveal android folder
-
Right click "gradlew" file and select Open in Terminal -
- Go to the terminal view and paste:
gradlew signingReport
(edit based on Venkat D. suggestion below: on unix-based systems like mac, you need to specify the current directory like this- ./gradlew signingReport)
- Press enter and scroll to "Variant: debug" to get the SHA1 key
- Copy and use wherever you need it, Good Luck!
Solution 3
You won't find a gradle window view in flutter project, so here is a solution for that.. In command prompt navigate to bin folder of jdk and run this command
keytool -list -v -keystore "C:\Users\yourusernamehere\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
change user name in path
Solution 4
I partially agree with Rishab answer, but what we can do is
and this approach works with all flutter/React-native/Android
....
Navigate to Android folder inside project, there is gradlew file. so we can use this like :
gradlew signingReport
in Mac
./gradlew signingReport
in my case i use it like :
D:\flutter\flutter_app\android>gradlew signingReport
Project Architecture is :
Solution 5
so if you are using an android studio or VS code it's work both of them
=> Open Terminal
=> cd android
=> signingReport
and the final output like this as given in the image below choice your SSH key in at the place of here is your SSH key
in the above output, image is shown in dummy data I change some of the fields just because of security purpose
Edit: for mac
./gradlew signingReport
Joseph Arriaza
I am a full stack developer that have knowledge in a lot of technologies, like front end frameworks, like Angular, AngularJS, ReactJS, etc, also I have a knowledge using back end technologies, building APIs using Java, PHP & C#. In my current work, we give services to companies in the US, so far, I have worked for Telecom Service Bureau building APIs and Front End interfaces, and also I work for Front Stream giving support to its system.
Updated on February 07, 2022Comments
-
Joseph Arriaza about 2 years
I'm trying to generate a SHA-1 for a Flutter app, for Android studio to support Google Sign in, but I don't know how to do that, I saw some posts that indicate to run a command, but there I need a jks file I guess, and flutter doesn't create that.
Could someone help me?
-
temirbek about 5 yearsit takes time for configuring process
-
Vikas Jangra over 4 yearsWorth mentioning that on unix-based systems like mac, you need to specify the current directory like ./gradlew signingReport
-
Marco Alves over 4 years@Mattias that was one of the best comments i have ever seen here!
-
BIS Tech over 4 yearsIs it want to add all sha key to firebase? and after added sha, is it need to replace google-service.json file?
-
sh0umik over 4 yearsThe Only Detailed Solution that is working for my flutter project. Thank you a lot <3
-
Dani over 4 yearsI cannot see the "Open for Editing in Android Studio" option
-
EslamWael74 over 4 years./gradlew signingReport
-
G.Busato over 4 yearsEasyest solution by far ! once you will have enter ./gradlew signinReport, the SH1 key will be prompted
-
awaik about 4 yearsIn this case on mac you can use keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
-
awaik about 4 yearsfor mac command is keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
-
giorgio79 about 4 yearsShould be the accepted asnwer for Flutter projects :)
-
Ananta Prasad about 4 yearsPerfect answer for Flutter
-
Dean Villamia almost 4 years- the simpler the better <3
-
kokoko almost 4 yearsIn my case it was "import Gradle project" for my Flutter app. But had to wait for indexing a bit.
-
Zephania Mwando almost 4 yearsWorked like magic, only I had a hard time figuring out on the second step opening Gradle yet it is on the right android studio by default. I hope that helps someone.
-
August Kimo over 3 yearsthe
./
isn't needed for me in Windows. This works usinggradlew signingReport
-
devu mani over 3 yearsAlso, you can directly open the
android
(project name -> android) as an android project -
William Herrmann about 3 yearsFor those of us that get an error about JAVA_HOME not being set, I updated my environment variables and added a System variable named
JAVA_HOME
set toC:\Program Files\Android\Android Studio\jre
. Then I updated my Path variable and added%JAVA_HOME%\bin
. Then this answer worked for me. -
NullByte08 about 3 yearsIf you cannot see the "Open in Android Studio" option, close your Flutter project. In Android Studio -> Open the
android
module of the flutter project in Android Studio from its path. -
Dani about 3 yearsThe Gradle Console tab has been replaced by "Build" in Android Studio 3.1, accessible from View -> Tool Windows -> Build.
-
Jay Tillu about 3 yearsThis one give me the
debug
key. How can I get therelease
key. So that I can use it for production. -
Jay Tillu about 3 yearsThis one gives me the debug key. How can I get the release key? So that I can use it for production.
-
Shishir almost 3 yearsThank you this helps!
-
Bhargav Sejpal almost 3 years./gradlew signingReport
-
Eric Aya almost 3 yearsSame solution already posted in other answers such as stackoverflow.com/a/58518934/2227743
-
Saiful Islam almost 3 yearsthis is one of the easy solutions out there. thank you. upvoted
-
Vaishnavi Sood almost 3 yearsThank you, none of the answers were working, I was disappointed, but at last this worked.
-
nipunasudha almost 3 yearsthis is the best , the most elegant & fool proof solution
-
Shreyansh Sharma over 2 yearsOne of the best answers I have ever seen.
-
KYL3R over 2 years@WilliamHerrmann - I got the
JAVA_HOME
error, too, but Android Studio told me to run it usingctrl+return
which runs it in the IDE instead of the terminal - that worked for me, too. -
leylekseven over 2 yearsFor ubuntu - android studio correct command or usage; right cicl to project/android/gradlew "run gradlew option> after that in below terminal screen, press up keyword and use; /bin/bash "your android studio folders path"/AndroidStudioProjects/project_folder/android/gradlew signingReport
-
malik kurosaki over 2 yearswork for me ,flutter on vscode "cd android && ./gradlew signinReport"
-
Choy over 2 years'keytool' is not recognized as an internal or external command, operable program or batch file.
-
Dinith Herath about 2 yearsThis solved the API exception PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)
-
mohannadalnono about 2 yearsthat's work, please add linux command to your answer so it'll benefit more people: in linux instead of just type gradlew we write ./gradlew to build. and to get SHA-1 we write: Terminal> ./gradlew signinReport and we could just build and get SHA-1 key with just one command: Terminal> ./gradlew signinReport
-
chrisu.chrisu about 2 yearsWhy my key is much longer than others. I also would like to achieve auth in flutter with microsoft, stackoverflow.com/questions/71338563/…
-
Anandh Krishnan about 2 yearsHappy coding with your 1 k+ reputition
-
Apoorv Pandey about 2 years@mohannadalnono Updated, and thanks for your input. Please check and correct me if anything is wrong.
-
bbjay about 2 yearsIf you can't see gradle tasks in the gradle tool, see this question: stackoverflow.com/questions/67405791/…
-
Sharath B Naik about 2 yearsYou nailed it. I'm linux user. Spent 4+ hours to slove. Finally. Thanks a lot
-
Atish Paul almost 2 yearsUpdate, Now windows users will have to write same as Mac: ./gradlew signingReport