Generating SHA-1 For Android (The Simplest Way)
In this article I’m going to explain the simplest and the easiest way to generate SHA-1 (Secure Hash Algorithm-1) for Android.
Actually I’m not going to talk about what exactly the SHA-1 is, or what does it mean.
But in some cases in Android it’s required to generate SHA-1 to use some services such as (Google Sign-in, Dynamic Links, etc…).
So, Let’s GO!
Step 1 : Generate keystore.jks File
As you do for generating signing apk. We can do that in Android Studio by clicking (Build -> Generate Signed APK…) then create new… and fill the information required such as (keystore path, keystore password, keyAlias, etc…).
Note : I recommend store the keystore.jks file in the same directory of project.
Tip : You can easily navigate to your project directory by clicking the small Android Studio logo in (choose keystore file) Dialog.
Step 2 : Add Signing Configs to your Gradle
In order to automate your APK building process you can add your signing configuration to your gradle.build. Hence, you can generate APK by running gradle task ( just one click ).
To do that, Click ( File ->Project Structure… ).
In the Modules section choose app and navigate to Signing tab. You should see this window.
Click the green plus button. This will create an new signing configuration for you and you have to provide the missing information (That you created ealier).
Then navigate to Build Types Tab and choose release. In Signing Config dropdown choose your config.
Now to can go to your build.gradle to see your signingConfigs added like that
Tip : You can replace your store file full path with ($rootDir) variable to avoid conflicts of root paths if you work with other members on the same project.
Tip : You can now automate generating Signing APK from the gradle tasks.
Step 3 : Generating SHA-1
Now you can easily navigate to the Gradle tab on the right side of Android Studio and run the signingReport task.
After running this task you will find all you need in the run tab as shown :
Your debug and release SHA-1 now available for you. Wow!