cloudwheels
cloudwheels

Reputation: 23

How do I generate SHA-1 for Flutter app from Linux command line

I'm trying to generate an SHA-1 for the android debug build of Flutter app so that I can use Firebase Authentication methods which require that (e.g. phone authentication dynamic links).

I have seen a number of solutions suggesting using the Gradle window in Android Studio, but this is not applicable for a Flutter project.

I understand I can do this from the command line using the java keytool utility.

This solution is available for the Windows command line but I am using *nix (Debian Linux on a Chromebook).

Also, I do not have the full Java JDK installed.

Upvotes: 1

Views: 583

Answers (2)

cloudwheels
cloudwheels

Reputation: 23

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)

Upvotes: 0

Jay Mungara
Jay Mungara

Reputation: 7150

First create a flutter project and open in android studio.

Then select android package.

In android package, select gradlew file. Right click on it and select option "open in terminal"

Then in terminal command line, add the command below

gradlew signingReport

Then It will list SHA1 & SHA256 and you're done.

Upvotes: 1

Related Questions