Generate SHA-1 for Flutter app

2020-02-02 06:25发布

问题:

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?

回答1:

How get Release and Debug keys: one more the easiest way (May 2019). All actions are inside Android Studio.

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

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

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



回答2:

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



回答3:

This is the easiest way-

  1. Open Android Studio

  2. Open Project

  3. Reveal android folder

  4. Right click gradlew file and select Open in Terminal -

  1. Go to the terminal view and paste - gradlew signingReport

  1. Press enter and scroll to Variant debug to get the SHA1 key

  1. Copy and use wherever you need it, Good Luck!


回答4:

I partially agree with Rishab answer, but what we can do is

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 :



回答5:

There are many ways you can do this, this is the easiest way I found.

Step 1: Open Project in Android Studio.

Step 2: Step 3: Find your SHA1 key in the signing report below in your android studio.

Hope it helped you..!



回答6:

You can generate it even from terminal. Following is for the release mode:

keytool -list -v -keystore keystore_location -alias alias_name

example :

keytool -list -v -keystore /home/user/key.jks -alias alias_name


回答7:

you can do the same on VSCode, open the folder that contain gradlew for linux and gradlew.bat for windows and run ./gradlew signingReport for linux and run gradlew signingReport for windows



回答8:

Check this Authenticating Your Client  |  Google APIs for Android

To get the debug certificate fingerprint:

for Mac or Linux

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

for Windows

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

The default password for the debug keystore is android.

The keytool then prints the fingerprint to the terminal.



标签: dart flutter